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

Jaypan’s picture

You need to install something that will look for autoloaded classes I use the xautoload module myself.

oskar_calvo’s picture

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

Jaypan’s picture

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?