Manual Installation
git clone https://github.com/charlar/symfony-admin.git AdminBundle
AdminBundle folder in either:
/Symfony/src/ (if using Symfony 2.3+ with autoloading)/Symfony/vendor/bundles/ (legacy Symfony 2.x)AppKernel.php:
$bundles[] = new CRL\AdminBundle\CRLAdminBundle();
Route Configuration
Add the admin route in app/config/routing.yml (or routing_dev.yml):
_admin:
resource: "@CRLAdminBundle/Controller/AdminController.php"
type: annotation
prefix: /admin
First Use Case
/admin in your browser.Entity-Based CRUD
Customization via Annotations
@Admin\Title, @Admin\List).use CRL\AdminBundle\Annotation as Admin;
/**
* @Admin\Title("Custom Title")
* @Admin\List(columns={"id", "name"})
*/
class Product {}
Form Customization
CRLAdminBundle:Admin:form.html.twig in your theme.Security Integration
ROLE_ADMIN).security.yml:
access_control:
- { path: ^/admin, roles: ROLE_ADMIN }
Event Listeners
prePersist, postUpdate) via Symfony’s event dispatcher.$dispatcher->addListener('admin.pre_save', function ($event) {
$entity = $event->getEntity();
// Custom logic before save
});
Manual Installation Quirks
AdminBundle directory is named exactly AdminBundle (case-sensitive).composer.json autoload:
"autoload": {
"psr-4": { "CRL\\AdminBundle\\": "src/" }
}
Then run composer dump-autoload.Entity Detection Issues
Entity namespace by default.config.yml:
crl_admin:
entity_namespaces: ["AppBundle\Entity", "Vendor\\Bundle\\Entity"]
Form Field Mapping
ArrayCollection) may not render correctly out-of-the-box.services.yml:
services:
app.form.type.my_collection:
class: AppBundle\Form\Type\MyCollectionType
tags: { name: form.type, alias: my_collection }
Routing Conflicts
_admin to prevent conflicts with the bundle’s route.Check Entity Annotations
doctrine:schema:validate command to ensure entities are properly annotated:
php app/console doctrine:schema:validate
Enable Debug Mode
APP_DEBUG=true in .env to see detailed errors in the admin interface.Clear Cache
php app/console cache:clear
Custom Templates
app/Resources/CRLAdminBundle/views/ to modify UI.AdminBundle:Admin:list.html.twig to your theme.Add Custom Actions
AdminController to add bulk actions or custom buttons.// In a custom controller extending AdminController
public function bulkDeleteAction() {
// Logic for bulk delete
}
Localization
translations/:
# app/Resources/translations/messages.en.yml
crl_admin:
add: "Create New"
edit: "Modify"
How can I help you explore Laravel packages today?