Installation:
composer require aropixel/admin-bundle
Register the bundle in config/bundles.php:
return [
// ...
Aropixel\AdminBundle\AropixelAdminBundle::class => ['all' => true],
];
First Use Case: Generate a CRUD interface for an existing entity:
php bin/console aropixel:make:crud
Follow prompts to specify your entity and form type (e.g., App\Entity\Post, App\Form\PostType).
Access Admin Panel: Create an admin user:
php bin/console aropixel:admin:create-user
Log in at /admin (default route).
CRUD Generation:
make:crud to scaffold controllers, templates, and routes.src/Controller/Admin/ and templates/admin/[entity]/.datatable_body or formbody.DataTables:
$dataTableFactory->create(Post::class)
->setColumns([
['label' => 'Title', 'orderBy' => 'title'],
['label' => 'Actions', 'orderBy' => '', 'class' => 'no-sort'],
]);
{% import '@AropixelAdmin/Macro/actions.html.twig' as list %}
{{ list.actions(item, path('admin_post_edit', {id: item.id}), path('admin_post_delete', {id: item.id})) }}
Forms:
ImageType, EditorType):
$builder->add('content', EditorType::class);
$builder->add('thumbnail', ImageType::class, ['data_class' => PostImage::class]);
{% import '@AropixelAdmin/Macro/forms.html.twig' as forms %}
{{ forms.tabs([
{ id: 'tab-content', label: 'Content' },
{ id: 'tab-media', label: 'Media' }
]) }}
Menu/Page Management:
PageBundle for hierarchical content:
php bin/console aropixel:make:crud App\Entity\Page App\Form\PageType
AdminUser entity.translations/messages.en.yaml:
admin:
post:
title: 'Blog Post'
assets/admin/ and import via Twig:
{{ encore_entry_link_tags('admin') }}
Entity Requirements:
id, createdAt, and updatedAt fields. Add these if missing:
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(type: 'datetime_immutable')]
private \DateTimeImmutable $createdAt;
FormType Mismatches:
FormType class specified in make:crud matches the entity’s fields. Mismatches cause runtime errors.Route Conflicts:
/admin/posts) may clash with existing routes. Override in config/routes.yaml:
aropixel_admin:
resource: "@AropixelAdminBundle/Resources/config/routing.yaml"
prefix: "/custom-admin"
LiipImagine Dependencies:
ImageType, ensure liip/imagine-bundle is installed and filters are configured in config/packages/liip_imagine.yaml.Template Overrides:
actions) don’t render, verify the Twig import path:
{% import '@AropixelAdmin/Macro/actions.html.twig' as list %}
datatable_body vs. datatableBody).DataTable Issues:
php bin/console cache:clear
Custom Macros:
src/Resources/views/Macro/ and document them in macros.md.Form Type Extensions:
ImageType) by creating a custom class:
class CustomImageType extends ImageType {
public function configureOptions(OptionsResolver $resolver) {
$resolver->setDefaults(['custom_option' => true]);
}
}
Admin Menu:
templates/admin/base.html.twig:{% block admin_menu %}
<li><a href="{{ path('admin_posts') }}">{{ 'admin.posts'|trans }}</a></li>
{% endblock %}
Translation Keys:
translations/messages.en.yaml and reference them in templates:
{{ 'admin.custom_label'|trans }}
How can I help you explore Laravel packages today?