eduardoledo/generic-admin-bundle
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:
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.
Enable the bundle in the kernel:
<?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:
<?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(),
);
}
Note: FOSUserBundle and Makerlabs/PagerBundle MUST be loaded BEFORE GenericAdminBundle
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
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
}
You have to add a section for each entity in config.yml:
# 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
For each entity you have to create a section with the following parameters:
Acme\DemoBundle\Controller\UsersController::indexAction would be acme_demo_users_index and the route_prefix would be acme_demo_usersLast but not least, we add the basic routes for the admin to function:
# app/config/routing.yml
lomaswifi_admin:
resource: "@LomaswifiAdminBundle/Controller/"
type: annotation
prefix: /
If everything went as planned you can now test the GenericBundleAdmin at http://your_server_url/admin.
Enjoy
How can I help you explore Laravel packages today?