Plugin Prefix sub name spaces

I have a plugin called ‘Users’, with a ‘Users’ controller. I’m prefix routing a ‘Client’ prefix. The plugin loads, but the prefix controller is not found.

Folder Structure:

The URL for access: localhost/drone/client/users/users/register

I get a UsersController could not be found message.

How would I sub-namespace the controller to get found?

First of all, your folder structure is wrong.
It should be plugins/Users/src/Controller/Client/UsersController.php (note the addition of src).
Second, I recommend to use a vendor namespace as well:

Then you need to define the UsersController like so:

namespace MyCompany/Users/Controller/Client/UsersController;

use MyCompany/Users/Controller/AppController.php;

class UsersController extends AppController {
  // magic

then you should make a route that points to it instead of that link think you have (trust me, it’ll get spaghetti that way)

1 Like