A generic, easy to use CRUD generator for Symfony2

Installs: 21

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0



dev-master 2014-04-11 20:38 UTC

This package is not auto-updated.

Last update: 2022-01-22 01:29:36 UTC


A generic, easy to use CRUD generator for Symfony2


This version of the bundle requires FOSUserBundle, Makerlabs PagerBundle and StfalconTinymceBundle. Both packages are installed automatically if not found.


Installation is a quick 3 steps process:

  1. Download GenericAdminBundle using composer
  2. Enable the bundle
  3. Create your controller class
  4. Configure the GenericAdminBundle
  5. Import the GenericAdminBundle routing

Step 1: Download FOSUserBundle using composer

Add GenericAdminBundle in your composer.json:

    "require": {
        "eduardoledo/generic-admin-bundle": "*"

Now tell composer to download the bundle by running the command:

$ php composer.phar update eduardoledo/generic-admin-bundle

Composer will install the bundle to your project's vendor/eduardoledo directory.

Step 2: Enable the bundle

Enable the bundle in the kernel:

// app/AppKernel.php
public function registerBundles()
    $bundles = array(
        // ...
        new Lomaswifi\AdminBundle\LomaswifiAdminBundle(),

If you did'n previusly installed FOSUserBundle, Makerlabs/PagerBundle or StfalconTinymceBundle you also have to enable them in the kernel which would look something like this:

// app/AppKernel.php
public function registerBundles()
    $bundles = array(
        // ...
        new FOS\UserBundle\FOSUserBundle(),
        new MakerLabs\PagerBundle\MakerLabsPagerBundle(),
        new Stfalcon\Bundle\TinymceBundle\StfalconTinymceBundle(),
        new Lomaswifi\AdminBundle\LomaswifiAdminBundle(),

Note: FOSUserBundle and Makerlabs/PagerBundle MUST be loaded BEFORE GenericAdminBundle

Step 3: Create your Controller class

In order to have all the corresponding routes and actions, you need to create a controller class for each entity that you want to have a CRUD, extending \Lomaswifi\AdminBundle\Entity\myController or a subclass:


namespace Acme\DemoBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

 * @Route("/admin/users")
class UsersController extends \Lomaswifi\AdminBundle\Entity\myController

    protected $section = 'user';    // The section name you used in the config.yml


Step 4: Configure the GenericAdminBundle

You have to add a section for each entity in config.yml:

# app/config/config.yml
            title: Users                                        # Title shown in CRUD
            singular: user
            plural: users
            route_prefix: acme_demo_users                  # Route prefix
            entity: AcmeDemoBundle:User                         # Entity alias
            form_class: \Lomaswifi\BlogBundle\Form\PostType
            form_service: fos_user.registration.form
                    name: username
                    label: username
                    name: email
                    label: Email

For each entity you have to create a section with the following parameters:

  • Title: the section title.
  • singular: the singular name of the entity
  • plural: the plural name of the entity
  • route_prefix: the prefix of the routes for the controller, as generated by symfony for routes without explicit name, based on namespace. In this example the route prefix for Acme\DemoBundle\Controller\UsersController::indexAction would be acme_demo_users_index and the route_prefix would be acme_demo_users
  • entity: the entity alias
  • form_class/form_service: the form fully qualified classname or form service for the entity
  • fields: an array with the names and labels of the fields you wish to display in the CRUD listing

Step 5: Import the GenericAdminBundle routing

Last but not least, we add the basic routes for the admin to function:

# app/config/routing.yml
    resource: "@LomaswifiAdminBundle/Controller/"
    type:     annotation
    prefix:   /

Next step

If everything went as planned you can now test the GenericBundleAdmin at http://your_server_url/admin.