Installing EasyAdmin

Video not working?

It looks like your browser may not support the H264 codec. If you're using Linux, try a different browser or try installing the gstreamer0.10-ffmpeg gstreamer0.10-plugins-good packages.

Thanks! This saves us from needing to use Flash or encode videos in multiple formats. And that let's us get back to making more videos :). But as always, please feel free to message us.

Well hey friends! We are in for a treat with this tutorial! It's EasyAdmin: my favorite admin generator for Symfony. It just... gives you so many features out of the box. And it looks great! This shouldn't really be a surprise because its creator is the always-impressive Javier Eguiluz.

So let's have some fun and learn how to bend EasyAdmin to our will. Because getting a lot of features for free is great... as long as we can extend it to do crazy things when we need to.

Project Setup

To squeeze the most "easy" out of EasyAdmin, you should definitely code along with me. You probably know the drill: download the course code from this page and unzip it to find a start/ directory with the same code that you see here. Check out the README.md file for all the setup goodies. I've already done all of these steps except for two.

For the first, find your terminal and run:

yarn install

I ran this already to save time... so I'll skip to compiling my assets with:

yarn watch

You can also run:

yarn dev-server

Which can do cool things like update your CSS without refreshing.

Perfect! For the second thing, open up another tab and run:

symfony serve -d

This fires up a local web server - using the Symfony binary - at https://127.0.0.1:8000. I'll be lazy by holding Cmd and clicking the link to pop open my browser. Say "hello" to... Cauldron Overflow! If you've been doing our Symfony 5 series, you're definitely familiar with this project. But, this is a Symfony 6 project, not Symfony 5:

100 lines composer.json
{
... lines 2 - 3
"require": {
... lines 5 - 15
"symfony/asset": "6.0.*",
"symfony/console": "6.0.*",
"symfony/dotenv": "6.0.*",
... line 19
"symfony/framework-bundle": "6.0.*",
... line 21
"symfony/runtime": "6.0.*",
"symfony/security-bundle": "6.0.*",
"symfony/stopwatch": "6.0.*",
"symfony/twig-bundle": "6.0.*",
... line 26
"symfony/yaml": "6.0.*",
... lines 28 - 29
},
"require-dev": {
... line 32
"symfony/debug-bundle": "6.0.*",
... line 34
"symfony/var-dumper": "6.0.*",
"symfony/web-profiler-bundle": "6.0.*",
... line 37
},
... lines 39 - 98
}

Oooo. If you are using Symfony 5, don't worry: very little will be different.

You don't need to worry too much about the majority of the code inside the project. The most important thing is probably our src/Entity/ directory. Our site has questions, and each Question has a number of answers. Each Question belongs to a single Topic... and then we have a User entity.

Our goal in this tutorial is to create a rich admin section that allows our admin users to manage all of this data.

Installing EasyAdmin

So let's get EasyAdmin installed! Find your terminal and run:

composer require admin

This is a Flex alias for easycorp/easyadmin-bundle. Notice that it downloads the shiny new version 4 of EasyAdmin, which only works with Symfony 6. So if you're using Symfony 5, run:

$ composer require admin:^3

to get version 3. Right now, version 4 and version 3 are identical, so you won't notice any differences. But going forward, new features will only be added to version 4.

Cool! Now that this is installed, what's next? Ship it!? Well, before we start deploying and celebrating our success... if we want to actually see something on our site, we're going to need a dashboard. Let's generate that next!

Leave a comment!

What PHP libraries does this tutorial use?

// composer.json
{
    "require": {
        "php": ">=8.0.2",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "composer/package-versions-deprecated": "^1.11", // 1.11.99.4
        "doctrine/doctrine-bundle": "^2.1", // 2.5.5
        "doctrine/doctrine-migrations-bundle": "^3.0", // 3.2.1
        "doctrine/orm": "^2.7", // 2.10.4
        "easycorp/easyadmin-bundle": "^4.0", // v4.0.2
        "handcraftedinthealps/goodby-csv": "^1.4", // 1.4.0
        "knplabs/knp-markdown-bundle": "dev-symfony6", // dev-symfony6
        "knplabs/knp-time-bundle": "^1.11", // 1.17.0
        "sensio/framework-extra-bundle": "^6.0", // v6.2.5
        "stof/doctrine-extensions-bundle": "^1.4", // v1.7.0
        "symfony/asset": "6.0.*", // v6.0.1
        "symfony/console": "6.0.*", // v6.0.2
        "symfony/dotenv": "6.0.*", // v6.0.2
        "symfony/flex": "^2.0.0", // v2.0.1
        "symfony/framework-bundle": "6.0.*", // v6.0.2
        "symfony/mime": "6.0.*", // v6.0.2
        "symfony/monolog-bundle": "^3.0", // v3.7.1
        "symfony/runtime": "6.0.*", // v6.0.0
        "symfony/security-bundle": "6.0.*", // v6.0.2
        "symfony/stopwatch": "6.0.*", // v6.0.0
        "symfony/twig-bundle": "6.0.*", // v6.0.1
        "symfony/ux-chartjs": "^2.0", // v2.0.1
        "symfony/webpack-encore-bundle": "^1.7", // v1.13.2
        "symfony/yaml": "6.0.*", // v6.0.2
        "twig/extra-bundle": "^2.12|^3.0", // v3.3.7
        "twig/twig": "^2.12|^3.0" // v3.3.7
    },
    "require-dev": {
        "doctrine/doctrine-fixtures-bundle": "^3.3", // 3.4.1
        "symfony/debug-bundle": "6.0.*", // v6.0.2
        "symfony/maker-bundle": "^1.15", // v1.36.4
        "symfony/var-dumper": "6.0.*", // v6.0.2
        "symfony/web-profiler-bundle": "6.0.*", // v6.0.2
        "zenstruck/foundry": "^1.1" // v1.16.0
    }
}