admin-platform/admin-bundle
Symfony bundle for building an admin platform using Sylius components. Install via Composer and register PlatformAdminBundle in AppKernel to add admin tooling and infrastructure to your Symfony application.
Installation
composer require admin-platform/admin-bundle "dev-master"
Note: Use "dev-master" only for testing; pin to a stable version in production.
Enable the Bundle
Add to config/bundles.php (Symfony 4+) or AppKernel.php (Symfony 3):
return [
// ...
Platform\Bundle\AdminBundle\PlatformAdminBundle::class => ['all' => true],
];
First Use Case: CRUD for an Entity
config/admin/resources/my_entity.yaml):
resources:
my_entity:
driver: orm
entity: App\Entity\MyEntity
grid:
fields:
- { property: 'id', type: 'string' }
- { property: 'name', type: 'string' }
form:
fields:
name: ~
php bin/console cache:clear
/admin/my_entity to see the auto-generated admin panel.config/admin/resources/*.yaml for entity-specific admin panels.templates/admin/ (see Symfony templating).Entity Admin Panels
grid:
fields:
- { property: 'createdAt', type: 'datetime', label: 'Created At' }
filters:
- { type: 'string', property: 'name', label: 'Name' }
actions:
- { type: 'edit' }
- { type: 'delete' }
form:
fields:
name:
type: 'Symfony\Component\Form\Extension\Core\Type\TextType'
options:
attr:
placeholder: 'Enter name'
Reusing Components
imports:
- { resource: '@PlatformAdminBundle/Resources/config/admin/resources/base_crud.yaml' }
Event Listeners
pre_update, post_create) via Symfony’s event system:
// src/EventListener/MyEntityListener.php
class MyEntityListener implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
AdminEvents::PRE_UPDATE => 'onPreUpdate',
];
}
public function onPreUpdate(AdminUpdateEvent $event): void
{
$entity = $event->getSubject();
// Modify entity before save
}
}
Custom Actions
grid:
actions:
- { type: 'custom', label: 'Export', route: 'admin_my_entity_export', icon: 'download' }
ROLE_ADMIN or custom roles to restrict access:
# config/packages/security.yaml
access_control:
- { path: ^/admin, roles: ROLE_ADMIN }
translations/admin.en.yaml:
admin:
my_entity:
name: 'Custom Name Field'
php bin/console assets:install
Override CSS/JS in web/bundles/platformadmin/.Cache Dependencies
php bin/console cache:clear
debug:config to verify loaded configs:
php bin/console debug:config platform_admin
Entity Metadata Conflicts
#[ORM\Table(name: 'custom_table')], ensure the admin config matches the table name.table option in the resource config:
resources:
my_entity:
driver: orm
table: 'custom_table'
Sylius Component Quirks
sylius/resource) may conflict with Doctrine extensions.config/bundles.php or use override: false in config/packages/doctrine.yaml:
doctrine:
orm:
mappings:
app: ~
dql:
string_functions:
override: false
Translation Fallbacks
php bin/console debug:translation platform_admin
Enable Debug Mode
Set APP_DEBUG=true in .env to see detailed errors and logs.
Log Admin Events
Enable event logging in config/packages/monolog.yaml:
handlers:
admin_events:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.admin.log"
level: debug
channels: ["platform_admin"]
Check Database Queries
Use Symfony’s profiler (/_profiler) to inspect SQL queries for slow admin panels.
Custom Drivers
// src/Admin/Driver/CustomDriver.php
class CustomDriver implements DriverInterface
{
public function load(): array { /* ... */ }
}
services.yaml:
services:
Platform\Bundle\AdminBundle\Driver\CustomDriver:
tags: [platform_admin.driver]
Dynamic Configs
// src/Admin/ConfigLoader/DynamicLoader.php
class DynamicLoader implements ConfigLoaderInterface
{
public function load(string $resourceName): array
{
return $this->fetchFromDatabase($resourceName);
}
}
API Integration
# config/routes.yaml
admin_api:
resource: "@PlatformAdminBundle/Resources/config/routing/api.yaml"
prefix: /api/admin
How can I help you explore Laravel packages today?