I could be wrong, but as the Composer PSR-0 autoloader converts underscores to sub folders, unless your Base_Controller is called Controller and is in a folder called Base, it may not autoload.
http://www.php-fig.org/psr/psr-0/#underscores-in-namespaces-and-class-names
Try using StudlyCaps and see how you go.
You also need to reference the controller name in the route:
Route::get('/', array('as'=>'home', 'uses'=>'QuestionsController@index'));
And any reason you don't just have a straight index()
method?
You seem to want to over-complicate things. Keep it simple (forget named routes, your own ideas, etc) and follow the conventions laid out in the docs.
If in doubt, use artisan to create your resful controller:
php artisan make:controller QuestionsController
Thanks Dave! As I said, I'm new to Laravel. So if I tend to over-complicate things; that is because I lack experience. Anyway using the Artisan command in the terminal fixed the issue. However I noticed, Laravel extends to Controller and not BaseController in the file they've created for me. I guess things have changed in the new version.
No probs, glad to help. I'm also new to Laravel, but luckily not PHP or frameworks :)
You can simply modify the code if you want to extend from a superclass. Laravel's autoloading (I presume, just a PHP autoloader) should find it.
Read up on namespacing, as the namespaces will map to folders!
Good luck :)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community