Akelos Modules

Akelos Modules

Akelos Modules allow you to group, multiple controllers into an organized manner. So instead of having all your controllers in one single place you can break them into different places.

In order to tell Akelos which modules are available, you need to add a rule to map requests to the new module so it can be dispatched by the specific controller.

Routes, Mapping Requests to your modules

Lets say you want to group all your administration controllers and views into an admin module.

You'll need to edit your config/routes.php file to make your application aware of this new module by adding

$Map->connect('/admin/:controller/:action/:id', array('controller' => 'dashboard', 'action' => 'index', 'module' => 'admin'));

before other routes.

Controller

Now you can place the dashboard controller at app/controllers/admin/dashboard_controller.php declaring the controller with a new convention. Prefix the controller name with the ModuleName + “_”“

class Admin_DashboardController extends AdminController
{
    //...
}

you can either extend from the base ApplicationController or from a module specific controller like we did on the code above. Akelos will look for a controller named after your module in this case at app/controllers/admin_controller.php and if exists it will be loaded so your Admin_DashboardController can extend from it

class AdminController extends ApplicationController
{
}

Views

Akelos will look for views at be at /app/views/admin/controller_name, and for helpers at /app/helpers/admin/

If you want to have a module specific layout Akelos will set by default app/views/layouts/admin.tpl for you.

Migrations

Installers can also be scoped to modules. In this case we could have several installers/migrations at app/installers/admin/*_installer.php. The only requirement right now is that you tell the installer which module it belongs to like

app/installers/admin/user_installer.php

class UserInstaller extends AkInstaller
{
    var $module = 'admin';
    // ***
}

Generators

The controller generator supports generating modular controllers doing like this:

./script/generate controller Admin::Users
 
modules.txt · Last modified: 2009/12/17 03:08 by 83.53.234.124
 

The Akelos Framework was created by Bermi Ferrer and other contributors.
Potions of the code and documentation have been ported from Ruby on Rails.

The Akelos Framework is released under the LGPL license.

"Akelos", "Akelos Framework", and the Akelos logo are trademarks of Bermi Labs All rights reserved.

Wiki driven by DokuWiki