📌  相关文章
📜  $ composer require easycorp easyadmin-bundle (1)

📅  最后修改于: 2023-12-03 14:38:43.767000             🧑  作者: Mango

EasyAdmin Bundle

The EasyAdmin Bundle is a Symfony bundle that provides a powerful and flexible admin dashboard for your application. With minimal configuration, you can easily manage your entities (CRUD operations), customize the look and feel of your dashboard, and add advanced features such as filters, security guards, and form themes.

Installation

To install the EasyAdmin Bundle, simply use Composer:

$ composer require easycorp easyadmin-bundle
Configuration

Once installed, you can start configuring the EasyAdmin Bundle by creating an easy_admin.yaml file in your application's config/packages directory.

Example configuration:

    easy_admin:
        design:
            # Set the site name to appear in the top navbar
            brand:
                name: 'My App'
            
            # Customize the appearance of the dashboard
            css:
                - '/css/easyadmin.css'

        entities:
            # Configure the entities to manage
            My\Entity\Example:
                class: My\Entity\Example
                label: 'Examples'
                list:
                    fields:
                        - id
                        - name
                        - created_at
                    actions:
                        - { name: 'show', label: 'View' }
                        - { name: 'edit', label: 'Edit' }
                        - { name: 'delete', label: 'Delete', confirm: true }
                form:
                    fields:
                        - name
                        - description
                        - { property: 'parent', type: 'entity', type_options: { class: 'My\Entity\Example' } }
                        
            My\Entity\Another:
                class: My\Entity\Another
                label: 'Another Entity'
                list:
                    fields:
                        - id
                        - title
                        - created_at
                        - { property: 'category.name', label: 'Category' }
                    actions:
                        - { name: 'show', label: 'View' }
                        - { name: 'edit', label: 'Edit' }
                        - { name: 'delete', label: 'Delete', confirm: true }
                form:
                    fields:
                        - title
                        - body
                        - { property: 'category', type: 'entity', type_options: { class: 'My\Entity\Category', property: 'name' } }
                
        # Configure the default routes for the dashboard
        easy_admin_bundle:
            site_name: 'My App Dashboard'
            design:
                favicon_path: '/images/favicon.png'
                formats:
                    date: 'Y-m-d'
                    datetime: 'Y-m-d H:i:s'
Usage

With the EasyAdmin Bundle, you can easily manage your entities through a powerful and flexible admin dashboard. Simply navigate to the /admin route of your application and start managing your entities.

Conclusion

The EasyAdmin Bundle is a powerful and flexible Symfony bundle that provides a powerful and customizable admin dashboard for managing your application's entities. With minimal configuration, you can easily add CRUD operations, customize the look and feel of your dashboard, and add advanced features such as filters, security guards, and form themes.