Install Dependencies
composer require symfony/templating deveosys/deveosys_admin "dev-master"
Enable Bundles
Add to AppKernel.php:
new EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle(),
new FOS\UserBundle\FOSUserBundle(),
new Deveosys\AdminBundle\DeveosysAdminBundle(),
Configure Routing
Add to routing.yml:
deveosys_admin:
resource: "@DeveosysAdminBundle/Resources/config/routing.yml"
prefix: /admin
Basic Configuration
Create config/deveosysAdmin.yml:
easy_admin:
site_name: '<YourApp> Admin'
design:
templates:
layout: '@DeveosysAdmin/layouts.html.twig'
First Use Case
Access /admin to see the pre-configured EasyAdmin dashboard with FOSUserBundle integration (users, roles, permissions).
User Management
Entity configuration:
# config/easy_admin.yml
easy_admin:
entities:
FOS\UserBundle\Entity\User:
class: AppBundle\Entity\User
list:
fields: ['username', 'email', 'enabled', 'roles']
form:
fields: ['username', 'email', 'plainPassword', 'roles']
Bootstrap 4 Integration
templates/easy_admin/ to customize:
{# templates/easy_admin/crud/index.html.twig #}
{% extends '@DeveosysAdmin/crud/index.html.twig' %}
{% block stylesheets %}
{{ parent() }}
<link href="/path/to/custom.css" rel="stylesheet">
{% endblock %}
Dynamic Admin Panels
// src/DeveosysAdminBundle/DependencyInjection/Compiler/Pass.php
public function process(ContainerBuilder $container) {
$definition = $container->findDefinition('deveosys_admin.entity_manager');
$definition->addMethodCall('addEntity', ['AppBundle\Entity\Post']);
}
Permission-Based Access
permission option:
easy_admin:
entities:
AppBundle\Entity\Post:
permission: 'ROLE_ADMIN'
AppKernel.php with config/bundles.php:
return [
// ...
Deveosys\AdminBundle\DeveosysAdminBundle::class => ['all' => true],
];
stof/doctrine-extensions-bundle for soft deletes, timestamps, etc., in EasyAdmin CRUD.Bundle Order Matters
ClassNotFoundException for FOSUserBundle or EasyAdminBundle.DeveosysAdminBundle is loaded after FOSUserBundle and EasyAdminBundle in AppKernel.php.Twig Template Overrides
templates/easy_admin/ (not templates/DeveosysAdmin/). Clear cache:
php bin/console cache:clear
Routing Conflicts
/admin routes clash with other bundles.prefix: /app_admin in routing.yml or adjust DeveosysAdminBundle's routes.FOSUserBundle Configuration
fos_user is configured in config/packages/security.yaml:
security:
firewalls:
main:
form_login:
provider: fos_userbundle
config/packages/dev/debug.yaml:
framework:
router:
debug: "%kernel.debug%"
php bin/console debug:container deveosys_admin to inspect service configurations.Custom Actions
# config/easy_admin.yml
easy_admin:
entities:
AppBundle\Entity\Post:
actions:
- { name: 'publish', icon: 'fa fa-bullhorn', label: 'Publish' }
// src/Controller/Admin/PostAdminController.php
public function publishAction(EntityManager $em, Post $post) {
$post->setPublishedAt(new \DateTime());
$em->flush();
return $this->redirectToRoute('easyadmin', ['entity' => 'Post']);
}
Event Listeners
EasyAdminEvent::PRE_PERSIST):
// src/EventListener/AdminListener.php
public static function getSubscribedEvents() {
return [
EasyAdminEvents::PRE_PERSIST => 'onPrePersist',
];
}
public function onPrePersist(PrePersistEvent $event) {
$entity = $event->getEntity();
if ($entity instanceof User) {
$entity->setLastLogin(new \DateTime());
}
}
Dynamic Field Configuration
easy_admin.yml:
easy_admin:
entities:
AppBundle\Entity\Product:
list:
fields: ['name', '%deveosys_admin.product_price%']
// src/Service/ProductPriceService.php
public function getPrice(Product $product) {
return '$' . $product->getPrice();
}
API Integration
api_platform or custom controllers:
// src/Controller/Admin/ApiController.php
#[Route('/admin/api/posts', name: 'admin_api_posts', methods: ['GET'])]
public function listPosts(EntityManagerInterface $em): JsonResponse {
$posts = $em->getRepository(Post::class)->findAll();
return new JsonResponse($posts);
}
How can I help you explore Laravel packages today?