如何在laravel中制作模块化系统

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.

  1. How can I call session classes in modules?
  2. I have route.php file in every module but still can't route the modules. Hence I am supposed to use laravel default routes.php file. How can I solve this problem?

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.