Reputation: 230
I have folder structure app/Http/Controllers/School inside which I have a SchoolController:
namespace School;
class SchoolController extends BaseSchoolController {.....
and BaseSchoolController:
namespace School
class BaseSchoolController extends \BaseController {....
(BaseController is in parent Controllers folder)
class BaseController extends Controller {...
This gives an error:
FatalErrorException in SchoolController.php line 5: Class 'School\BaseSchoolController' not found
Any ideas, thanks?
Seems happy with this structure though:
class SchoolController extends \Controller {
Upvotes: 1
Views: 1058
Reputation: 1840
From what I can see right away, the namespaces are wrong.
Laravel 5 uses PSR-4, which means that each namespace must match the folder structure (including the vendor) of a class file.
So, for app/Http/Controllers/School/SchoolController.php
, the namespace should be set to:
<?php namespace App\Http\Controllers\School;
not just
<?php namespace School;
Also, if the app name isn't the default one (App
), change it accordingly on the namespace.
As an example, if you ran:
php artisan app:name ACME
the namespace should then be:
<?php namespace ACME\Http\Controllers\School;
Check other classes like app/Http/Controllers/Auth/AuthController.php
, to have an idea how it should be done.
Upvotes: 1