Here is the simplified error:
InvalidArgumentException: Class "\Drupal\prepcart\Controller\PrepCartController" does not exist. in Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition() (line 24 of core/lib/Drupal/Core/DependencyInjection/ClassResolver.php).
Full Stack Trace:
The website encountered an unexpected error. Please try again later. InvalidArgumentException: Class "\Drupal\prepcart\Controller\PrepCartController" does not exist. in Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition() (line 24 of core/lib/Drupal/Core/DependencyInjection/ClassResolver.php). Drupal\Core\Controller\ControllerResolver->createController('\Drupal\prepcart\Controller\PrepCartController::content') (Line: 74) Drupal\Core\Controller\ControllerResolver->getControllerFromDefinition('\Drupal\prepcart\Controller\PrepCartController::content', '/cart') (Line: 91) Drupal\Core\Controller\ControllerResolver->getController(Object) (Line: 132) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64) Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57) Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47) Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 98) Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 77) Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23) Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 628) Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Relevant information: Drupal Core 8.1.8 (I know 8.2 is out but this shouldn't matter I believe - we are pinned to this version due to Lightning)
And here is the relevant files involved:
PrepCartController.php
<?php
/**
* @file
* Contains \Drupal\prepcart\Controller\PrepCartController.
*/
namespace Drupal\prepcart\Controller;
use Drupal\Core\Controller\ControllerBase;
class PrepCartController extends ControllerBase {
public function content() {
return array(
'#type' => 'markup',
'#markup' => $this->t('Hello, IHM!'),
);
}
};
To make life easier this is the directory structure:
drwxr-xr-x 170B Oct 18 07:05 ./
-rw-r--r-- 222B Oct 18 06:36 ./prepcart.info.yml
-rw-r--r-- 195B Oct 18 07:05 ./prepcart.routing.yml
drwxr-xr-x 102B Oct 18 06:53 ./src/
drwxr-xr-x 102B Oct 18 06:54 ./src/Controller/
-rw-r--r-- 349B Oct 18 06:54 ./src/Controller/PrepCartController.php
For some reason the module won't show on the modules page but I can interact with it fine on the CLI using drush?
Trust me when I say I have been ALL over Google and Stack for this. Major love to whomever can help me here.