Home ›
Error when Drupal 8 class file is misplacedError when Drupal 8 class file is misplaced
Submitted by Benjamin Melançon on June 7, 2014 - 4:42pm
The error is pretty straightforward but the sheer confusion of where to place class files in your module (first off, yes, they do go in your module) might make this a pretty commonly googled error.
Drupal may give an error like this:
Error
The website has encountered an error. Please try again later.
Look in your logs for more detail:
tail -f -n100 /var/log/apache2/error.log
Here's the key problem:
[Fri Jun 06 18:05:01.084354 2014] [:error] [pid 12348] [client 127.0.0.1:41897] Uncaught PHP Exception InvalidArgumentException: "Class "\\Drupal\\testexample\\Controller\\TestexampleController" does not exist." at /home/ben/code/drupal/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php line 29
Solution, in my case, i had to move the controller class file in my module from the incorrect location src/Controller/Testexample/TestexampleController.php to the correct location (without the extra nesting of the module name) src/Controller/TestexampleController.php.
Searched words:
Uncaught PHP Exception InvalidArgumentException Class Drupal does not exist drupal/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php
class .php library file doesn't exist
Comments
Post new comment