I am trying to create a modular system in Laravel 4.1.
I have folders like following:
app
app/controllers
app/controllers/BaseController.php
app/views/
app/modules/
app/modules/moduleName/
app/modules/moduleName/routes.php
app/modules/moduleName/controllers/
app/modules/moduleName/controllers/module.php
When I try to extend BaseController
, I use namespaces and I get the following error:
Symfony \ Component \ Debug \ Exception \ FatalErrorException
Class 'Illuminate\Session' not found
Here is my module.php codes:
<?php namespace App\Modules\Twitter\Controllers;
use Illuminate\Routing\Controllers\Controller;
class Modulename extends Controller {
}
I have two questions.
Thanks anyway.
Laravel libraries all exist in the global namespace, so if you're using namespaced code of any sort, you'll need to specify the libraries you're calling.
Using the code you provided, it'd be like this:
<?php namespace App\Modules\Twitter\Controllers;
use Controller, Session;
class Modulename extends Controller {
}
This saves you having to type out the entire namespace.