0
votes

Ok so I am finally getting around to building an application in Laravel, hopefully in the correct way. I am assuming that using packages to bundle core modules such as 'User', 'Admin' e.t.c is the correct future proof way of doing things.

Anyway, I am working on my User package and well running into trouble adding my controllers. I keep getting the

Class RegistrationController does not exist

error from Laravel. As the error suggests it cannot find the class RegistrationController in my package from the package routes file:

Route::get('user/register', 'RegistrationController@create')->before('guest');
Route::post('user/register', ['as' => 'registration.store', 'uses' => 'RegistrationController@store']);

And here is the start of my controller:

<?php namespace Vendorname\Package\Controllers;

    class RegistrationController extends \BaseController {

My controllers are located in Vendorname/Package/src/controllers and my packages composer file's autoload looks like this:

"autoload": {
    "classmap": [
        "src/migrations",
        "src/controllers"
    ],

Where am I going wrong?

1
Your controller is called Vendorname\Package\Controllers\RegistrationController, not RegistrationController.Maerlyn

1 Answers

0
votes

Create routes.php file in your package and register your routes there.