Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By oskar_calvo on
Hello, I'm trying to develop a private module in d7, and I'm trying to use the psr-4 to load the class
Mi class is in /sites/all/modules/mymodule/src/Controller/MyclassPage404.php
And I have a static method call: render
My namespace is: Drupal\mymodule\src\Controller;
I'm trying this in the hook_menu
'page callback' => '\Drupal\mymodule\Controller\MyclassPage404::render'
But I only get
Fatal error: Class 'Drupal\mymodule\Controller\MymodulePage404' not found in
Thanks.
Oskar
Comments
You need to install something
You need to install something that will look for autoloaded classes I use the xautoload module myself.
Hello Jaypan.
Hello Jaypan.
I have it installed, but until I don't use require_once to load the file/class it doesn't work.
I have to add any especial configuration to use xautoload?
Oskar
you need to remove src from
you need to remove
src
from your namespace. Also, is the filename the same as your class name, and does it have a .php file extension?