PHPackages                             pablodip/module-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. pablodip/module-bundle

ActiveSymfony-bundle[Framework](/categories/framework)

pablodip/module-bundle
======================

Symfony PablodipModuleBundle

2.1.x-dev(13y ago)159023MITPHPPHP &gt;=5.3.2

Since Oct 9Pushed 12y ago1 watchersCompare

[ Source](https://github.com/pablodip/PablodipModuleBundle)[ Packagist](https://packagist.org/packages/pablodip/module-bundle)[ Docs](https://github.com/pablodip/PablodipModuleBundle)[ RSS](/packages/pablodip-module-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (4)Used By (0)

PablodipModuleBundle
====================

[](#pablodipmodulebundle)

[![Build Status](https://camo.githubusercontent.com/3b8143ababd3f465d600b5e4c4195fc4dbdbcc5f201c6426fe68029179726269/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f7061626c6f6469702f5061626c6f6469704d6f64756c6542756e646c652e706e67)](http://travis-ci.org/pablodip/PablodipModuleBundle) [![Scrutinizer Quality Score](https://camo.githubusercontent.com/4bf64a50aeb6fc161a299f5c68f6cae4ac9c04632dcf405ad224dc0dcdd32919/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7061626c6f6469702f5061626c6f6469704d6f64756c6542756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f733d32383664313432653934303162373531373937646537323065346238383437653439313735646439)](https://scrutinizer-ci.com/g/pablodip/PablodipModuleBundle/)

1. [Introduction](#introduction)
2. [Creating modules](#creating-modules)
3. [Making modules reusable](#making-modules-reusable)
4. [Extensions](#extensions)
5. [Reusing modules](#reusing-modules)

Introduction
------------

[](#introduction)

The aim of a Symfony2 application is to transform HTTP requests in HTTP responses. This is done by the controllers through the routes, so that you can say the controllers are the most important part of a Symfony2 application, as everything else is managed by them.

Symfony2 offers you flexibility for working with controllers and routes. A controller can be any PHP callable, and a route can be defined in many formats, like YAML, XML, PHP, annotations. This flexibility is good, but sometimes your applications become mess and also it's difficult to reuse things between applications.

The PablodipModuleBundle allows you to organize your controllers and routes in modules, so that they become organized and reusable. Organized controllers are those who follow some order rule and keep related things together. Reusable modules are those which you can easily make customizable and use them again in the same project or in other project.

The common rule for organizing controllers is to put them into the `Controller` directory inside the bundles. Their names sometimes coincide with model names and also you usually have some controllers for static actions.

How should you organize a blog, by putting all its controllers in the same controller class or by splitting them in different classes? If you have a bundle dedicated only to the blog, it would make sense to split the controllers. But then, how would you make that bundle reusable? How would you allow to customize its behavior? By putting parameters in the container? By creating fields in a database? Would not be better to allow the user to customize them the way he wants, through the container, a database or whatever? Also how would you create reusable themes for the blog? The template overriding provided by Symfony2 is great, but it doesn't allow you to create themes. Also, how would you allow to use the blog several times in the same project? It would be difficult due to it uses only one set of routes and they are hardcoded in the controllers and templates.

We'll see how to use the PablodipModuleBundle to solve all these problems.

Creating modules
----------------

[](#creating-modules)

In order to convert an HTTP request in an HTTP response you need a controller (also called action) and a route to access to that controller. A module is a group of related actions. Both actions and modules are represented by classes.

```
