Symfony News

EasyAdmin 3 is released

EasyAdmin is an admin generator for Symfony applications. It helps you generate the backend of your projects by solving all the repetitive stuff (listing data, pagination, sorting, creating/updating entities, etc.)

EasyAdmin was created as a simpler (and less powerful) alternative to SonataAdmin. Originally, it took inspiration from symfony 1 admin generator and the entire backend was configured using a YAML file. This was nice for quickly creating backends, but made maintenance harder and creating complex backends nearly impossible.

A few days ago, after several months of hard work, EasyAdmin 3 was released. This new version is a complete revamp of the previous version. EasyAdmin no longer uses YAML and everything is configured with PHP code.

This is for example how to define a Dashboard that links to the CRUD operations (create, edit, list/show and delete) of some Doctrine entities:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
namespace App\Controller\Admin;

use App\Entity\Blog\Comment;
use App\Entity\Blog\Post;
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;

class DashboardController extends AbstractDashboardController
{
    public function configureDashboard(): Dashboard
    {
        return Dashboard::new()->setTitle('ACME Inc.');
    }

    public function configureMenuItems(): iterable
    {
        yield MenuItem::section('Blog');
        yield MenuItem::linkToCrud('Posts', 'fa fa-file-text-o', Post::class);
        yield MenuItem::linkToCrud('Comments', 'far fa-comments', Comment::class);

        // ...
    }
}

EasyAdmin provides several commands to create the initial structure of these PHP classes (make:admin::dashboard, make:admin:crud). A key feature of the new EasyAdmin is that it stays as close to Symfony as possible. A “dashboard controller” is just a regular Symfony controller with a few custom methods, so you can use all Symfony controller features, you can access to your services, etc.

EasyAdmin uses tens of Symfony components, which provide an exceptional and rock-solid foundation to develop the project on top of them. This includes some of the newest components such as Symfony String and Symfony Uid. The String component is a personal favorite of mine because it allows you to write super clean and readable code:

1
2
// needed to turn 'foo' into '$foo' and 'foo.bar.baz' into '$fooBarBaz'
$newName = u($name)->replace('.', ' ')->camel()->collapseWhitespace()->toString();

This example is part of the migration command (make:admin:migration), which automatically turns the EasyAdmin 2 YAML configuration file into the PHP files used by EasyAdmin 3.

If you want to give EasyAdmin 3 a try in your project, run this command:

1
$ composer require easycorp/easyadmin-bundle:^3.0

You can also read EasyAdmin docs and visit the EasyAdmin blog, where you’ll find some technical articles explaining the most important changes made in this new version.

Thanks to all the developers who contributed to EasyAdmin 3 and thanks to the Symfony community in general for all their support.


Sponsor the Symfony project.


About us

What a Symfony developer should know about the framework: News, Jobs, Tweets, Events, Videos,...

Resources

Find us on Twitter

Find us on Facebook