Skip to content
  • About
    • What is Symfony?
    • Community
    • News
    • Contributing
    • Support
  • Documentation
    • Symfony Docs
    • Symfony Book
    • Screencasts
    • Symfony Bundles
    • Symfony Cloud
    • Training
  • Services
    • Platform.sh for Symfony Best platform to deploy Symfony apps
    • SymfonyInsight Automatic quality checks for your apps
    • Symfony Certification Prove your knowledge and boost your career
    • SensioLabs Professional services to help you with Symfony
    • Blackfire Profile and monitor performance of your apps
  • Other
  • Blog
  • Download
sponsored by SensioLabs
  1. Home
  2. Documentation
  3. Bundles
  4. SonataAdminBundle
  5. Console/Command-Line Commands
  • Documentation
  • Book
  • Reference
  • Bundles
  • Cloud

Table of Contents

  • cache:create-cache-class
  • make:sonata:admin
  • sonata:admin:list
  • sonata:admin:explain
  • sonata:admin:setup-acl
  • sonata:admin:generate-object-acl

Console/Command-Line Commands

Edit this page

Console/Command-Line Commands

SonataAdminBundle provides the following console commands:

  • cache:create-cache-class
  • make:sonata:admin
  • sonata:admin:list
  • sonata:admin:explain
  • sonata:admin:setup-acl
  • sonata:admin:generate-object-acl

cache:create-cache-class

The cache:create-cache-class command generates the cache class (var/cache/...env.../classes.php) from the classes.map file.

1
bin/console cache:create-cache-class

make:sonata:admin

The make:sonata:admin command generates a new Admin class based on the given model class, registers it as a service and potentially creates a new controller. As an argument you need to specify the fully qualified model class. All passed arguments and options are used as default values in interactive mode. You can disable the interactive mode with --no-interaction option.

The command require the Symfony Maker Bundle to work. If you don't already have it, you can install it with :

1
composer require symfony/maker-bundle --dev
Options Description
model The fully qualified model class, e.g. "AppEntityFoo"
admin the admin class basename (by default this adds "Admin" to the model class name, e.g. "FooAdmin")
controller the controller class basename (by default this adds "AdminController" to the model class name, e.g. "FooAdminController")
manager the model manager type (by default this is the first registered model manager type, e.g. "orm")
services the services YAML file (the default value is "services.yaml")
id the admin service ID (the default value is combination of "admin" and admin class basename like "admin.foo_bar")
1
bin/console make:sonata:admin App/Entity/Foo

sonata:admin:list

To see which admin services are available use the sonata:admin:list command. It prints all the admin service ids available in your application. This command gets the ids from the sonata.admin.pool service where all the available admin services are registered.

1
bin/console sonata:admin:list
List command

sonata:admin:explain

The sonata:admin:explain command prints details about the admin of a model. As an argument you need to specify the admin service id of the Admin to explain.

1
bin/console sonata:admin:explain sonata.news.admin.post
Explain command

sonata:admin:setup-acl

The sonata:admin:setup-acl command updates ACL definitions for all Admin classes available in sonata.admin.pool. For instance, every time you create a new Admin class, you can create its ACL by using the sonata:admin:setup-acl command. The ACL database will be automatically updated with the latest masks and roles.

1
bin/console sonata:admin:setup-acl

sonata:admin:generate-object-acl

The sonata:admin:generate-object-acl is an interactive command which helps you to generate ACL entities for the objects handled by your Admins. See the help of the command for more information.

1
bin/console sonata:admin:generate-object-acl
This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
TOC
    Version
    We stand with Ukraine.
    Version:
    Get your Sylius expertise recognized

    Get your Sylius expertise recognized

    Code consumes server resources. Blackfire tells you how

    Code consumes server resources. Blackfire tells you how

    Symfony footer

    ↓ Our footer now uses the colors of the Ukrainian flag because Symfony stands with the people of Ukraine.

    Avatar of Nate Wiebe, a Symfony contributor

    Thanks Nate Wiebe (@natewiebe13) for being a Symfony contributor

    18 commits • 1.56K lines changed

    View all contributors that help us make Symfony

    Become a Symfony contributor

    Be an active part of the community and contribute ideas, code and bug fixes. Both experts and newcomers are welcome.

    Learn how to contribute

    Symfony™ is a trademark of Symfony SAS. All rights reserved.

    • What is Symfony?

      • Symfony at a Glance
      • Symfony Components
      • Case Studies
      • Symfony Releases
      • Security Policy
      • Logo & Screenshots
      • Trademark & Licenses
      • symfony1 Legacy
    • Learn Symfony

      • Symfony Docs
      • Symfony Book
      • Reference
      • Bundles
      • Best Practices
      • Training
      • eLearning Platform
      • Certification
    • Screencasts

      • Learn Symfony
      • Learn PHP
      • Learn JavaScript
      • Learn Drupal
      • Learn RESTful APIs
    • Community

      • SymfonyConnect
      • Support
      • How to be Involved
      • Code of Conduct
      • Events & Meetups
      • Projects using Symfony
      • Downloads Stats
      • Contributors
      • Backers
    • Blog

      • Events & Meetups
      • A week of symfony
      • Case studies
      • Cloud
      • Community
      • Conferences
      • Diversity
      • Documentation
      • Living on the edge
      • Releases
      • Security Advisories
      • SymfonyInsight
      • Twig
      • SensioLabs
    • Services

      • SensioLabs services
      • Train developers
      • Manage your project quality
      • Improve your project performance
      • Host Symfony projects

      Deployed on

    Follow Symfony

    Search by Meilisearch