2017 © Pedro Peláez
 

symfony-bundle generic-admin-bundle

A generic, easy to use CRUD generator for Symfony2

image

eduardoledo/generic-admin-bundle

A generic, easy to use CRUD generator for Symfony2

  • Friday, April 11, 2014
  • by eduardoledo
  • Repository
  • 1 Watchers
  • 0 Stars
  • 17 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

GenericAdminBundle

A generic, easy to use CRUD generator for Symfony2, (*1)

Prerequisites

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

Installation

Installation is a quick 3 steps process:, (*3)

  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:, (*4)

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

Now tell composer to download the bundle by running the command:, (*5)

``` bash $ php composer.phar update eduardoledo/generic-admin-bundle, (*6)


Composer will install the bundle to your project's `vendor/eduardoledo` directory. ### Step 2: Enable the bundle Enable the bundle in the kernel: ``` php <?php // 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:, (*7)

``` php <?php // 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(), ); }, (*8)

**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:

``` php
<?php

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: ``` yaml, (*9)

app/config/config.yml

lomaswifi_admin: sections: user: 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 fields: username: name: username label: username email: name: email label: Email, (*10)

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:
``` yml
# app/config/routing.yml
lomaswifi_admin:
    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., (*11)

Enjoy, (*12)

The Versions

11/04 2014

dev-master

9999999-dev https://github.com/eduardoledo/GenericAdminBundle

A generic, easy to use CRUD generator for Symfony2

  Sources   Download

Unlicense

The Requires

 

symfony2 crud admin