0
votes

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.

1
Your tree is not enough, we will need to see some code, to try understand how you're doing things and what may be happening.Antonio Carlos Ribeiro
I just added intro codes of my module.Onur Göker

1 Answers

1
votes

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.