Username Password        Sign up Lost password

Create module structure

written by bcoos on 16 June 2012

Now we have bcoos installed but the default page when we go to our domain is to show blog/index action. But we can change this.

Our home page must be why/index, but at this time we don't have the why module.

To change default action to why/index we have to make few steps the first one is create a new module structure to hold our application.

Let's go to create the structure of why module.

A module contains a full application

The minimal folder structure of a bcoos module is the following:


Create the module folder structure inside a why folder.

In case we are making a foo module it would be inside a foo folder.

Module folder structure

The controller folder has one unique controller per module.

The controller have methods each one gets data from models and send it to the choosen view

The models folder can have one or more models.

Models get data from database and send it to controller

The view/themes/bcoos folder has the views files.

A view is a representation of the model

The views/themes/bcoos/blocks has the blocks files.

A block is a view embedded in a layout

The views/themes/bcoos/layouts has the layouts files.

A layout is a group of one view and 0 or more blocks

The views/themes/bcoos/css has the css files specific to module.
The views/themes/bcoos/js has the javascript files specific to module.
The views/themes/bcoos/images has the image files specific to module.

The tests folder has the tests specific to this module.

Minimal files at module structure

The minimal files a module can have are:


The model isn't necessary but without a model our site will be static.
For convention we name the model with the same name of module.

Create these three files with this content:


<?php // bcoos 2.0 GPL àèíóú UTF-8

class whyController extends bcoosController {

controller class naming moduleController


<?php // bcoos 2.0 GPL àèíóú UTF-8

class whyModel extends bcoosModel {

model class naming modelNameModel


<?php // bcoos 2.0 GPL àèíóú UTF-8 ?>

This is where the home page will go. 

Next chapter - Create the home page
Previous chapter - Install bcoos

Table of contents - How to make a Question / Answer site


View all tags bcoos why tutorial


Powered by bcoos 2.0 | 0.0105 seconds | 25 queries | SQL: 0.0017 seconds | 42 files: 322.73 KB | HTML: 17.94 KB