Flag of Ukraine
SymfonyCasts stands united with the people of Ukraine

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!

43
Login or Register to join the conversation
Ruslan Avatar

Thank you! :)

2 Reply
robspijkerman Avatar
robspijkerman Avatar robspijkerman | posted 11 months ago

Hi

I notice that Easy Admin has been updated since you did this tutorial, there is now no html.twig files and therefore no start point for creating the admin page which quite frankly makes it very difficult to proceed as it offers you 3 options that at this time mean very little therefore making it impossible to proceed further. Can you make this available for the tutorial please as it really confuses the whole start process.

Cheers

Rob

1 Reply
Andrzej S. Avatar
Andrzej S. Avatar Andrzej S. | posted 1 year ago

EasyAdmin 4 requires PHP 8.0.2 or higher and Symfony 5.4 or higher. Why did you say that it only for Symfony 6?

1 Reply

Hey Andrzej S.

I'm afraid there was a confusion. This tutorial uses Symfony 6 and PHP 8 but it doesn't mean that you can only run EasyAdmin on those versions. EasyAdmin comes with its own version constraints that you can check here https://github.com/EasyCorp...
I hope I managed to clarify the situation. Cheers!

1 Reply
Andrzej S. Avatar

Thanks for the reply, it's helpful.
By the way, I love your tutorials and I learned a lot from them.

Reply

Hi there,

I tried docker-compose up -d as in readme and I got the error

ERROR: Version mismatch: file ./docker-compose.yaml specifies version 3.7 but extension file ./docker-compose.override.yml uses version 3.0

Fixed the docker-composer.override.yml and it worked

1 Reply

Hey Rodrigo!

Sorry about that! It was fixed in https://github.com/SymfonyC... - thanks for head ups!

Cheers!

Reply
Nicolas-M Avatar
Nicolas-M Avatar Nicolas-M | posted 2 months ago | edited

I have an issue on installing the project.

When I run composer install, I get this error:

$ composer install

Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.

  Problem 1
    - laminas/laminas-code is locked to version 4.5.1 and an update of this package was not requested.
    - laminas/laminas-code 4.5.1 requires php >=7.4, <8.2 -> your php version (8.2.0) does not satisfy that requirement.
  Problem 2
    - laminas/laminas-code 4.5.1 requires php >=7.4, <8.2 -> your php version (8.2.0) does not satisfy that requirement.
    - friendsofphp/proxy-manager-lts v1.0.5 requires laminas/laminas-code ~3.4.1|^4.0 -> satisfiable by laminas/laminas-code[4.5.1].
    - friendsofphp/proxy-manager-lts is locked to version v1.0.5 and an update of this package was not requested.


When I run **composer update**, I get this error:

**$ composer update**
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Restricting packages listed in "symfony/symfony" to "6.0.*"
Updating dependencies
Lock file operations: 1 install, 80 updates, 3 removals
  - Removing friendsofphp/proxy-manager-lts (v1.0.5)
  - Removing laminas/laminas-code (4.5.1)
  - Removing symfony/polyfill-php73 (v1.24.0)
  - Upgrading behat/transliterator (v1.3.0 => v1.5.0)
  - Upgrading composer/package-versions-deprecated (1.11.99.4 => 1.11.99.5)
  - Upgrading doctrine/annotations (1.13.2 => 2.0.1)
  - Upgrading doctrine/cache (2.1.1 => 2.2.0)
  - Upgrading doctrine/collections (1.6.8 => 2.1.2)
  - Upgrading doctrine/common (3.2.1 => 3.4.3)
  - Upgrading doctrine/data-fixtures (1.5.1 => 1.6.3)
  - Upgrading doctrine/dbal (3.2.1 => 3.6.1)
  - Upgrading doctrine/deprecations (v0.5.3 => v1.0.0)
  - Upgrading doctrine/doctrine-bundle (2.5.5 => 2.9.0)
  - Upgrading doctrine/doctrine-fixtures-bundle (3.4.1 => 3.4.2)
  - Upgrading doctrine/doctrine-migrations-bundle (3.2.1 => 3.2.2)
  - Upgrading doctrine/event-manager (1.1.1 => 2.0.0)
  - Upgrading doctrine/inflector (2.0.4 => 2.0.6)
  - Upgrading doctrine/instantiator (1.4.0 => 1.5.0)
  - Upgrading doctrine/lexer (1.2.1 => 2.1.0)
  - Upgrading doctrine/migrations (3.3.2 => 3.6.0)
  - Upgrading doctrine/orm (2.10.4 => 2.14.1)
  - Upgrading doctrine/persistence (2.3.0 => 3.1.4)
  - Upgrading doctrine/sql-formatter (1.1.2 => 1.1.3)
  - Upgrading fakerphp/faker (v1.17.0 => v1.21.0)
  - Upgrading gedmo/doctrine-extensions (v3.4.0 => v3.11.1)
  - Upgrading knplabs/knp-time-bundle (1.17.0 => v1.20.0)
  - Upgrading monolog/monolog (2.3.5 => 2.9.1)
  - Upgrading nikic/php-parser (v4.13.2 => v4.15.4)
  - Upgrading sensio/framework-extra-bundle (v6.2.5 => v6.2.10)
  - Upgrading stof/doctrine-extensions-bundle (v1.7.0 => v1.7.1)
  - Upgrading symfony/asset (v6.0.1 => v6.0.19)
  - Upgrading symfony/cache (v6.0.2 => v6.0.19)
  - Upgrading symfony/cache-contracts (v3.0.0 => v3.2.1)
  - Upgrading symfony/config (v6.0.2 => v6.0.19)
  - Upgrading symfony/console (v6.0.2 => v6.0.19)
  - Upgrading symfony/debug-bundle (v6.0.2 => v6.0.19)
  - Upgrading symfony/dependency-injection (v6.0.2 => v6.0.20)
  - Upgrading symfony/deprecation-contracts (v3.0.0 => v3.2.1)
  - Upgrading symfony/doctrine-bridge (v6.0.2 => v6.0.19)
  - Upgrading symfony/dotenv (v6.0.2 => v6.0.19)
  - Upgrading symfony/error-handler (v6.0.2 => v6.0.19)
  - Upgrading symfony/event-dispatcher (v6.0.2 => v6.0.19)
  - Upgrading symfony/event-dispatcher-contracts (v3.0.0 => v3.2.1)
  - Upgrading symfony/filesystem (v6.0.0 => v6.0.19)
  - Upgrading symfony/finder (v6.0.2 => v6.0.19)
  - Upgrading symfony/flex (v2.0.1 => v2.2.5)
  - Upgrading symfony/framework-bundle (v6.0.2 => v6.0.19)
  - Upgrading symfony/http-foundation (v6.0.2 => v6.0.20)
  - Upgrading symfony/http-kernel (v6.0.2 => v6.0.20)
  - Upgrading symfony/maker-bundle (v1.36.4 => v1.48.0)
  - Upgrading symfony/monolog-bridge (v6.0.1 => v6.0.19)
  - Upgrading symfony/monolog-bundle (v3.7.1 => v3.8.0)
  - Upgrading symfony/password-hasher (v6.0.2 => v6.0.19)
  - Upgrading symfony/polyfill-intl-grapheme (v1.24.0 => v1.27.0)
  - Upgrading symfony/polyfill-intl-normalizer (v1.24.0 => v1.27.0)
  - Upgrading symfony/polyfill-mbstring (v1.24.0 => v1.27.0)
  - Upgrading symfony/polyfill-php80 (v1.24.0 => v1.27.0)
  - Upgrading symfony/polyfill-php81 (v1.24.0 => v1.27.0)
  - Upgrading symfony/property-access (v6.0.2 => v6.0.19)
  - Upgrading symfony/property-info (v6.0.2 => v6.0.19)
  - Upgrading symfony/routing (v6.0.1 => v6.0.19)
  - Upgrading symfony/runtime (v6.0.0 => v6.0.19)
  - Upgrading symfony/security-bundle (v6.0.2 => v6.0.20)
  - Upgrading symfony/security-core (v6.0.2 => v6.0.19)
  - Upgrading symfony/security-csrf (v6.0.1 => v6.0.19)
  - Upgrading symfony/security-http (v6.0.2 => v6.0.20)
  - Upgrading symfony/service-contracts (v3.0.0 => v3.2.1)
  - Upgrading symfony/stopwatch (v6.0.0 => v6.0.19)
  - Upgrading symfony/string (v6.0.2 => v6.0.19)
  - Locking symfony/templating (v6.0.19)
  - Upgrading symfony/translation (v6.0.2 => v6.0.19)
  - Upgrading symfony/translation-contracts (v3.0.0 => v3.2.1)
  - Upgrading symfony/twig-bridge (v6.0.2 => v6.0.19)
  - Upgrading symfony/twig-bundle (v6.0.1 => v6.0.19)
  - Upgrading symfony/var-dumper (v6.0.2 => v6.0.19)
  - Upgrading symfony/var-exporter (v6.0.0 => v6.2.8)
  - Upgrading symfony/web-profiler-bundle (v6.0.2 => v6.0.19)
  - Upgrading symfony/webpack-encore-bundle (v1.13.2 => v1.16.1)
  - Upgrading symfony/yaml (v6.0.2 => v6.0.19)
  - Upgrading twig/extra-bundle (v3.3.7 => v3.5.1)
  - Upgrading twig/twig (v3.3.7 => v3.5.1)
  - Upgrading zenstruck/assert (v1.0.0 => v1.3.0)
  - Upgrading zenstruck/callback (v1.4.1 => v1.5.0)
  - Upgrading zenstruck/foundry (v1.16.0 => v1.31.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Upgrading symfony/var-exporter (v6.2.7 => v6.2.8): Extracting archive
Package sensio/framework-extra-bundle is abandoned, you should avoid using it. Use Symfony instead.
Generating autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
70 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
What about running composer global require symfony/thanks && composer thanks now?
This will spread some love by sending a star to the GitHub repositories of your fellow package maintainers.
Run composer recipes at any time to see the status of your Symfony recipes.
Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 255
!!
!!  Fatal error: Declaration of Knp\Bundle\MarkdownBundle\Helper\MarkdownHelper::getCharset() must be compatible with Symfony\Component\Templating\Helper\HelperInterface::getCharset(): string in C:\Nicolas\Symfony\Easyadmin\Easy1\vendor\knplabs\knp-markdown-bundle\Helper\MarkdownHelper.php on line 53
!!  PHP Fatal error:  Declaration of Knp\Bundle\MarkdownBundle\Helper\MarkdownHelper::getCharset() must be compatible with Symfony\Component\Templating\Helper\HelperInterface::getCharset(): string in C:\Nicolas\Symfony\Easyadmin\Easy1\vendor\knplabs\knp-markdown-bundle\Helper\MarkdownHelper.php on line 53
!!  Symfony\Component\ErrorHandler\Error\FatalError^ {#1600
!!    #message: "Compile Error: Declaration of Knp\Bundle\MarkdownBundle\Helper\MarkdownHelper::getCharset() must be compatible with Symfony\Component\Templating\Helper\HelperInterface::getCharset(): string"
!!    #code: 0
!!    #file: "C:\Nicolas\Symfony\Easyadmin\Easy1\vendor\knplabs\knp-markdown-bundle\Helper\MarkdownHelper.php"
!!    #line: 53
!!    -error: array:4 [
!!      "type" => 64
!!      "message" => "Declaration of Knp\Bundle\MarkdownBundle\Helper\MarkdownHelper::getCharset() must be compatible with Symfony\Component\Templating\Helper\HelperInterface::getCharset(): string"
!!      "file" => "C:\Nicolas\Symfony\Easyadmin\Easy1\vendor\knplabs\knp-markdown-bundle\Helper\MarkdownHelper.php"
!!      "line" => 53
!!    ]
!!  }
!!
Script @auto-scripts was called via post-update-cmd

Any idea?

Thanks a lot since I have tried many things but with no success.

Reply

Hi @Nicolas-M,

We are sorry that you got this issue... As a fast solution install project with composer update laminas/laminas-code command. It should work with PHP 8.2.

Cheers and happy codding!

Reply
Nicolas-M Avatar
Nicolas-M Avatar Nicolas-M | sadikoff | posted 2 months ago | edited

Thanks Sadikoff,

I started again from scratch, and ran these commands in this order:

composer update laminas/laminas-code
composer require symfony/validator
composer install

But when I run:

composer update

I still get a blocking error which is mainly:

Compile Error: Declaration of Knp\Bundle\MarkdownBundle\Helper\MarkdownHelper::getCharset() must be compatible with Symfony\Component\Templating\Helper\HelperInterface::getCharset(): string

Hereafter is the complete return:

$ composer update

Deprecation Notice: Return type of Symfony\Flex\Response::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in C:\xampp\htdocs\Easy1\vendor\symfony\flex\src\Response.php:68
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Restricting packages listed in "symfony/symfony" to "6.0.*"
Updating dependencies
Lock file operations: 1 install, 80 updates, 3 removals
  - Removing friendsofphp/proxy-manager-lts (v1.0.5)
  - Removing laminas/laminas-code (4.10.0)
  - Removing symfony/polyfill-php73 (v1.24.0)
  - Upgrading behat/transliterator (v1.3.0 => v1.5.0)
  - Upgrading composer/package-versions-deprecated (1.11.99.4 => 1.11.99.5)
  - Upgrading doctrine/annotations (1.13.2 => 2.0.1)
  - Upgrading doctrine/cache (2.1.1 => 2.2.0)
  - Upgrading doctrine/collections (1.6.8 => 2.1.2)
  - Upgrading doctrine/common (3.2.1 => 3.4.3)
  - Upgrading doctrine/data-fixtures (1.5.1 => 1.6.5)
  - Upgrading doctrine/dbal (3.2.1 => 3.6.1)
  - Upgrading doctrine/deprecations (v0.5.3 => v1.0.0)
  - Upgrading doctrine/doctrine-bundle (2.5.5 => 2.9.0)
  - Upgrading doctrine/doctrine-fixtures-bundle (3.4.1 => 3.4.2)
  - Upgrading doctrine/doctrine-migrations-bundle (3.2.1 => 3.2.2)
  - Upgrading doctrine/event-manager (1.1.1 => 2.0.0)
  - Upgrading doctrine/inflector (2.0.4 => 2.0.6)
  - Upgrading doctrine/instantiator (1.4.0 => 1.5.0)
  - Upgrading doctrine/lexer (1.2.1 => 2.1.0)
  - Upgrading doctrine/migrations (3.3.2 => 3.6.0)
  - Upgrading doctrine/orm (2.10.4 => 2.14.1)
  - Upgrading doctrine/persistence (2.3.0 => 3.1.4)
  - Upgrading doctrine/sql-formatter (1.1.2 => 1.1.3)
  - Upgrading fakerphp/faker (v1.17.0 => v1.21.0)
  - Upgrading gedmo/doctrine-extensions (v3.4.0 => v3.11.1)
  - Upgrading knplabs/knp-time-bundle (1.17.0 => v1.20.0)
  - Upgrading monolog/monolog (2.3.5 => 2.9.1)
  - Upgrading nikic/php-parser (v4.13.2 => v4.15.4)
  - Upgrading sensio/framework-extra-bundle (v6.2.5 => v6.2.10)
  - Upgrading stof/doctrine-extensions-bundle (v1.7.0 => v1.7.1)
  - Upgrading symfony/asset (v6.0.1 => v6.0.19)
  - Upgrading symfony/cache (v6.0.2 => v6.0.19)
  - Upgrading symfony/cache-contracts (v3.0.0 => v3.2.1)
  - Upgrading symfony/config (v6.0.2 => v6.0.19)
  - Upgrading symfony/console (v6.0.2 => v6.0.19)
  - Upgrading symfony/debug-bundle (v6.0.2 => v6.0.19)
  - Upgrading symfony/dependency-injection (v6.0.2 => v6.0.20)
  - Upgrading symfony/deprecation-contracts (v3.0.0 => v3.2.1)
  - Upgrading symfony/doctrine-bridge (v6.0.2 => v6.0.19)
  - Upgrading symfony/dotenv (v6.0.2 => v6.0.19)
  - Upgrading symfony/error-handler (v6.0.2 => v6.0.19)
  - Upgrading symfony/event-dispatcher (v6.0.2 => v6.0.19)
  - Upgrading symfony/event-dispatcher-contracts (v3.0.0 => v3.2.1)
  - Upgrading symfony/filesystem (v6.0.0 => v6.0.19)
  - Upgrading symfony/finder (v6.0.2 => v6.0.19)
  - Upgrading symfony/flex (v2.0.1 => v2.2.5)
  - Upgrading symfony/framework-bundle (v6.0.2 => v6.0.19)
  - Upgrading symfony/http-foundation (v6.0.2 => v6.0.20)
  - Upgrading symfony/http-kernel (v6.0.2 => v6.0.20)
  - Upgrading symfony/maker-bundle (v1.36.4 => v1.48.0)
  - Upgrading symfony/monolog-bridge (v6.0.1 => v6.0.19)
  - Upgrading symfony/monolog-bundle (v3.7.1 => v3.8.0)
  - Upgrading symfony/password-hasher (v6.0.2 => v6.0.19)
  - Upgrading symfony/polyfill-intl-grapheme (v1.24.0 => v1.27.0)
  - Upgrading symfony/polyfill-intl-normalizer (v1.24.0 => v1.27.0)
  - Upgrading symfony/polyfill-mbstring (v1.24.0 => v1.27.0)
  - Upgrading symfony/polyfill-php80 (v1.24.0 => v1.27.0)
  - Upgrading symfony/polyfill-php81 (v1.24.0 => v1.27.0)
  - Upgrading symfony/property-access (v6.0.2 => v6.0.19)
  - Upgrading symfony/property-info (v6.0.2 => v6.0.19)
  - Upgrading symfony/routing (v6.0.1 => v6.0.19)
  - Upgrading symfony/runtime (v6.0.0 => v6.0.19)
  - Upgrading symfony/security-bundle (v6.0.2 => v6.0.20)
  - Upgrading symfony/security-core (v6.0.2 => v6.0.19)
  - Upgrading symfony/security-csrf (v6.0.1 => v6.0.19)
  - Upgrading symfony/security-http (v6.0.2 => v6.0.20)
  - Upgrading symfony/service-contracts (v3.0.0 => v3.2.1)
  - Upgrading symfony/stopwatch (v6.0.0 => v6.0.19)
  - Upgrading symfony/string (v6.0.2 => v6.0.19)
  - Locking symfony/templating (v6.0.19)
  - Upgrading symfony/translation (v6.0.2 => v6.0.19)
  - Upgrading symfony/translation-contracts (v3.0.0 => v3.2.1)
  - Upgrading symfony/twig-bridge (v6.0.2 => v6.0.19)
  - Upgrading symfony/twig-bundle (v6.0.1 => v6.0.19)
  - Upgrading symfony/var-dumper (v6.0.2 => v6.0.19)
  - Upgrading symfony/var-exporter (v6.0.0 => v6.2.8)
  - Upgrading symfony/web-profiler-bundle (v6.0.2 => v6.0.19)
  - Upgrading symfony/webpack-encore-bundle (v1.13.2 => v1.16.1)
  - Upgrading symfony/yaml (v6.0.2 => v6.0.19)
  - Upgrading twig/extra-bundle (v3.3.7 => v3.5.1)
  - Upgrading twig/twig (v3.3.7 => v3.5.1)
  - Upgrading zenstruck/assert (v1.0.0 => v1.3.0)
  - Upgrading zenstruck/callback (v1.4.1 => v1.5.0)
  - Upgrading zenstruck/foundry (v1.16.0 => v1.31.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 80 updates, 3 removals
  - Removing symfony/polyfill-php73 (v1.24.0)
  - Removing laminas/laminas-code (4.10.0)
  - Removing friendsofphp/proxy-manager-lts (v1.0.5)
  - Upgrading composer/package-versions-deprecated (1.11.99.4 => 1.11.99.5): Extracting archive
  - Upgrading symfony/flex (v2.0.1 => v2.2.5): Extracting archive
  - Upgrading symfony/runtime (v6.0.0 => v6.0.19): Extracting archive
  - Upgrading behat/transliterator (v1.3.0 => v1.5.0): Extracting archive
  - Upgrading symfony/polyfill-mbstring (v1.24.0 => v1.27.0): Extracting archive
  - Upgrading symfony/deprecation-contracts (v3.0.0 => v3.2.1): Extracting archive
  - Upgrading symfony/http-foundation (v6.0.2 => v6.0.20): Extracting archive
  - Upgrading symfony/event-dispatcher-contracts (v3.0.0 => v3.2.1): Extracting archive
  - Upgrading symfony/event-dispatcher (v6.0.2 => v6.0.19): Extracting archive
  - Upgrading symfony/var-dumper (v6.0.2 => v6.0.19): Extracting archive
  - Upgrading symfony/error-handler (v6.0.2 => v6.0.19): Extracting archive
  - Upgrading symfony/http-kernel (v6.0.2 => v6.0.20): Extracting archive
  - Upgrading symfony/service-contracts (v3.0.0 => v3.2.1): Extracting archive
  - Upgrading doctrine/event-manager (1.1.1 => 2.0.0): Extracting archive
  - Upgrading doctrine/persistence (2.3.0 => 3.1.4): Extracting archive
  - Upgrading symfony/doctrine-bridge (v6.0.2 => v6.0.19): Extracting archive
  - Upgrading symfony/polyfill-php81 (v1.24.0 => v1.27.0): Extracting archive
  - Upgrading symfony/dependency-injection (v6.0.2 => v6.0.20): Extracting archive
  - Upgrading symfony/polyfill-intl-normalizer (v1.24.0 => v1.27.0): Extracting archive
  - Upgrading symfony/polyfill-intl-grapheme (v1.24.0 => v1.27.0): Extracting archive
  - Upgrading symfony/string (v6.0.2 => v6.0.19): Extracting archive
  - Upgrading symfony/console (v6.0.2 => v6.0.19): Extracting archive
  - Upgrading symfony/filesystem (v6.0.0 => v6.0.19): Extracting archive
  - Upgrading symfony/config (v6.0.2 => v6.0.19): Extracting archive
  - Upgrading symfony/polyfill-php80 (v1.24.0 => v1.27.0): Extracting archive
  - Upgrading doctrine/deprecations (v0.5.3 => v1.0.0): Extracting archive
  - Upgrading doctrine/lexer (1.2.1 => 2.1.0): Extracting archive
  - Upgrading doctrine/instantiator (1.4.0 => 1.5.0): Extracting archive
  - Upgrading doctrine/inflector (2.0.4 => 2.0.6): Extracting archive
  - Upgrading doctrine/cache (2.1.1 => 2.2.0): Extracting archive
  - Upgrading doctrine/dbal (3.2.1 => 3.6.1): Extracting archive
  - Upgrading doctrine/common (3.2.1 => 3.4.3): Extracting archive
  - Upgrading doctrine/collections (1.6.8 => 2.1.2): Extracting archive
  - Upgrading doctrine/orm (2.10.4 => 2.14.1): Extracting archive
  - Upgrading symfony/routing (v6.0.1 => v6.0.19): Extracting archive
  - Upgrading symfony/finder (v6.0.2 => v6.0.19): Extracting archive
  - Upgrading symfony/var-exporter (v6.0.0 => v6.2.8): Extracting archive
  - Upgrading symfony/cache-contracts (v3.0.0 => v3.2.1): Extracting archive
  - Upgrading symfony/cache (v6.0.2 => v6.0.19): Extracting archive
  - Upgrading symfony/framework-bundle (v6.0.2 => v6.0.19): Extracting archive
  - Upgrading doctrine/sql-formatter (1.1.2 => 1.1.3): Extracting archive
  - Upgrading doctrine/doctrine-bundle (2.5.5 => 2.9.0): Extracting archive
  - Upgrading doctrine/data-fixtures (1.5.1 => 1.6.5): Extracting archive
  - Upgrading doctrine/doctrine-fixtures-bundle (3.4.1 => 3.4.2): Extracting archive
  - Upgrading symfony/stopwatch (v6.0.0 => v6.0.19): Extracting archive
  - Upgrading doctrine/migrations (3.3.2 => 3.6.0): Extracting archive
  - Upgrading doctrine/doctrine-migrations-bundle (3.2.1 => 3.2.2): Extracting archive
  - Upgrading symfony/translation-contracts (v3.0.0 => v3.2.1): Extracting archive
  - Upgrading symfony/translation (v6.0.2 => v6.0.19): Extracting archive
  - Installing symfony/templating (v6.0.19): Extracting archive
  - Upgrading knplabs/knp-time-bundle (1.17.0 => v1.20.0): Extracting archive
  - Upgrading doctrine/annotations (1.13.2 => 2.0.1): Extracting archive
  - Upgrading sensio/framework-extra-bundle (v6.2.5 => v6.2.10): Extracting archive
  - Upgrading gedmo/doctrine-extensions (v3.4.0 => v3.11.1): Extracting archive
  - Upgrading stof/doctrine-extensions-bundle (v1.7.0 => v1.7.1): Extracting archive
  - Upgrading twig/twig (v3.3.7 => v3.5.1): Extracting archive
  - Upgrading symfony/twig-bridge (v6.0.2 => v6.0.19): Extracting archive
  - Upgrading symfony/debug-bundle (v6.0.2 => v6.0.19): Extracting archive
  - Upgrading symfony/dotenv (v6.0.2 => v6.0.19): Extracting archive
  - Upgrading nikic/php-parser (v4.13.2 => v4.15.4): Extracting archive
  - Upgrading symfony/maker-bundle (v1.36.4 => v1.48.0): Extracting archive
  - Upgrading monolog/monolog (2.3.5 => 2.9.1): Extracting archive
  - Upgrading symfony/monolog-bridge (v6.0.1 => v6.0.19): Extracting archive
  - Upgrading symfony/monolog-bundle (v3.7.1 => v3.8.0): Extracting archive
  - Upgrading symfony/property-info (v6.0.2 => v6.0.19): Extracting archive
  - Upgrading symfony/password-hasher (v6.0.2 => v6.0.19): Extracting archive
  - Upgrading symfony/security-core (v6.0.2 => v6.0.19): Extracting archive
  - Upgrading symfony/property-access (v6.0.2 => v6.0.19): Extracting archive
  - Upgrading symfony/security-http (v6.0.2 => v6.0.20): Extracting archive
  - Upgrading symfony/security-csrf (v6.0.1 => v6.0.19): Extracting archive
  - Upgrading symfony/security-bundle (v6.0.2 => v6.0.20): Extracting archive
  - Upgrading symfony/twig-bundle (v6.0.1 => v6.0.19): Extracting archive
  - Upgrading symfony/web-profiler-bundle (v6.0.2 => v6.0.19): Extracting archive
  - Upgrading symfony/asset (v6.0.1 => v6.0.19): Extracting archive
  - Upgrading symfony/webpack-encore-bundle (v1.13.2 => v1.16.1): Extracting archive
  - Upgrading symfony/yaml (v6.0.2 => v6.0.19): Extracting archive
  - Upgrading twig/extra-bundle (v3.3.7 => v3.5.1): Extracting archive
  - Upgrading zenstruck/callback (v1.4.1 => v1.5.0): Extracting archive
  - Upgrading zenstruck/assert (v1.0.0 => v1.3.0): Extracting archive
  - Upgrading fakerphp/faker (v1.17.0 => v1.21.0): Extracting archive
  - Upgrading zenstruck/foundry (v1.16.0 => v1.31.0): Extracting archive
Package sensio/framework-extra-bundle is abandoned, you should avoid using it. Use Symfony instead.
Generating autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
71 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

What about running composer global require symfony/thanks && composer thanks now?
This will spread some love by sending a star to the GitHub repositories of your fellow package maintainers.

Run composer recipes at any time to see the status of your Symfony recipes.

Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 255**
!!**
!!  Fatal error: Declaration of Knp\Bundle\MarkdownBundle\Helper\MarkdownHelper::getCharset() must be compatible with Symfony\Component\Templating\Helper\HelperInterface::getCharset(): string in C:\xampp\htdocs\Easy1\vendor\knplabs\knp-markdown-bundle\Helper\MarkdownHelper.php on line 53
!!  Symfony\Component\ErrorHandler\Error\FatalError^ {#785
!!    #message: "Compile Error: Declaration of Knp\Bundle\MarkdownBundle\Helper\MarkdownHelper::getCharset() must be compatible with Symfony\Component\Templating\Helper\HelperInterface::getCharset(): string"
!!    #code: 0
!!    #file: "C:\xampp\htdocs\Easy1\vendor\knplabs\knp-markdown-bundle\Helper\MarkdownHelper.php"
!!    #line: 53
!!    -error: array:4 [
!!      "type" => 64
!!      "message" => "Declaration of Knp\Bundle\MarkdownBundle\Helper\MarkdownHelper::getCharset() must be compatible with Symfony\Component\Templating\Helper\HelperInterface::getCharset(): string"
!!      "file" => "C:\xampp\htdocs\Easy1\vendor\knplabs\knp-markdown-bundle\Helper\MarkdownHelper.php"
!!      "line" => 53
!!    ]
!!  }
!!  PHP Fatal error:  Declaration of Knp\Bundle\MarkdownBundle\Helper\MarkdownHelper::getCharset() must be compatible with Symfony\Component\Templating\Helper\HelperInterface::getCharset(): string in C:\xampp\htdocs\Easy1\vendor\knplabs\knp-markdown-bundle\Helper\MarkdownHelper.php on line 53
!!
Script @auto-scripts was called via post-update-cmd

Any idea, please?

Reply
Nicolas-M Avatar

Hi Sadikoff,
Finally, I downgraded the PHP version from 8.2 to 8.0.25.
And everything is back to normal.
Cheers,
Nicolas

Reply

Hey, sorry that I was not able to answer previous message, but yeah, sometimes it's better to use PHP version course was designed, it's pretty difficult to support all PHP versions, but I will re-check this course compatibility.

Thanks for you report!

Reply
Nicolas-M Avatar

No problem - I learned a lot from digging everywhere. :-)

Reply
excentrist Avatar
excentrist Avatar excentrist | posted 5 months ago | edited

An exception occurred in the driver: SQLSTATE[08006] [7] connection to server at "127.0.0.1", port 50051 failed: FATAL: password authentication failed for user "app"

What am I doing wrong? Nothing is working..

Reply

Hey @excentrist!

Sorry about the trouble! I believe this is caused by Symfony now shipping recipes with Postgres version 14 and your local machine probably already have a Docker instance using Postgres 13. I have some more info and the solution here - please let me know if it helps!

https://symfonycasts.com/screencast/symfony-doctrine/docker-compose#comment-28388

Cheers!

Reply
excentrist Avatar

Sorry, where's the solution exactly? lol

Reply

Oh geez ­čĄŽ - https://symfonycasts.com/screencast/symfony-doctrine/docker-compose#comment-28388 - here it is (also added to my original comment above). Sorry about that!

Reply
Estelle G. Avatar
Estelle G. Avatar Estelle G. | posted 1 year ago | edited

Hi, first of all thanks a million for your awesome tutorials, truly love them.
I'm running into a bit of an issue during install here and would appreciate some help.

I've just downloaded the start archive & followed the install steps (without Docker), I'm currently using PHP 8.1.4. I've tried switching back to 8.0.12 & 8.1.2 (I'm using Laragon + manually updating Windows env vars) but the same error occurs.

However whenever I launch the Symfony server, I get the following error & unfortunately I'm unable to reach http://127.0.0.1:8000 - it never loads.

<blockquote>|CRITICA| REQUES Uncaught PHP Exception Twig\Error\RuntimeError: "An exception has been thrown during the rendering of a template ("Class "App\Entity\Category" does not exist")." at C:\Users\estel\Desktop\Symfony\SymfonyCasts\code-easyadminbundle\start\templates\base.html.twig line 18</blockquote>

When I go to base.html.twig :

{{ is_granted('ROLE_PREVIOUS_ADMIN') ? 'style="background-color: red !important"' }}

I've tried closing & reopening VSCode, symfony server:stop & symfony serve again, but to no avail. Any help appreciated :) TIA

Reply

Hey Estelle G.

That's a very odd error because the entity Category does not exist in this project. Did you change something after downloading the start directory?
Try clearing your cache rm -rf var/cache and reinstall your vendors rm -rf vendor && composer install
Oh, and if you're on Windows, try using "localhost" instead of "127.0.0.1"

Cheers!

Reply
Estelle G. Avatar

Thanks for your reply. Well I am not sure what happened, possibly some sort of witchcraft ahah but well anyway after restarting my PC & this project today it now works perfectly fine, but thank you anyway :)

Reply
Tien dat L. Avatar
Tien dat L. Avatar Tien dat L. | posted 1 year ago | edited

Hallo, May i ask a question please?

I got missing translation messages in easyadmin 4
`
# symfony console debug:translation en --only-missing
State Domain Id Message Preview (en) Fallback Message Preview (de)


missing time diff.empty diff.empty diff.empty
missing EasyAdminBundle label.form.empty_value label.form.empty_value label.form.empty_value
`

I tried in app/translation/messages.en.yaml:
<br />label:<br />---- form:<br />-------- empty_value : abc<br />

but still got missing, how can i fix this thanks

Reply
Tien dat L. Avatar

in vendor/easycorp/easyadmin-bundle/src/Resources/translations/EasyAdminBundle.de.php
->i found 'label' => 'form.emtyp_value' => 'keine Wert'

...

Reply

Hey Luong,

Hm, sounds like a type in the message key, right? Good catch! It's a great opportunity to create a PR to the EasyAdminBundle. Are you going to do this?

Cheers!

1 Reply
Tien dat L. Avatar
Tien dat L. Avatar Tien dat L. | Victor | posted 1 year ago | edited

Hi @victor yes i try work around with symfony and easyadmin, is great :). But i dont know why i still got missing messager ?_? how can overrider translation von easyadmin in 'de' order fix this missing

1 Reply

Hey Luong,

Here's the link to the docs that shows how to override translations from third-party bundles: https://symfony.com/doc/cur... . But if there's a typo - it's better to send a PR and fix it upstream in the bundle's repo. Then, just upgrade to a new release that will contains those changes.

I hope this helps!

Cheers!

1 Reply

Bonjour! May I ask a question please?

I should use CAS bundle for my app because we use SSO system. So, can i use the following bundle while I use Symfony 6 because there is no CAS bundle for Symfony6:
https://github.com/ecphp/ca...

I really appreciate your support and your hard work! ^^

Reply

Hey Lubna,

Unfortunately, I've never worked with CAS protocol before, so don't use those bundles myself. But let me give you some hints. First of all, I see that the bundle you linked https://github.com/ecphp/ca... does not support Symfony 6 yet, though there's an issue about it: https://github.com/ecphp/ca... - feel free to follow it to know when that issue is closed. Also, if you have time - feel free to help with upgrading that bundle and make it compatible with Symfony 6 and send a PR - that may have a good side effect, because even if the bundle is slow on reviewing/merging your PR - you will be able to use *your* fork in your project while PR is not merged yet.

Other options - you may want to take a look at GitHub search: https://github.com/search?o... - probably you will find that is still maintained. If no luck - you may want to use low-level tools that are used in those bundles to write the implementation yourself - take a look at composer.json file to see what libs are used behind the scene in those bundles that might help you.

Or, another option - downgrade your project to Symfony 5.4. Basically, Symfony 5.4 == 6.0, but in Symfony 6.0 just dropped all the legacy code since 5.x version. Though, it might work and you will be able to install that bundle, but keep in mind that if the bundle is dead and nobody will add Symfony 6 support there - you won't be able to upgrade to the newer version at some point.

I hope this helps!

Cheers!

1 Reply

Many thanks for your helpful response! All is clear.

Reply

Hey Lubna,

Glad to hear it was helpful for you! And sorry that I can't help more with this problem

Cheers!

Reply

Hi again!

After downgrading my app I have a problem in my auth. Could you plz take a look at my error message as below:

An exception has been thrown during the rendering of a template ("Unable to find the current firewall LogoutListener, please provide the provider key manually.").

So, I had to add a logout path under the firewalls in my security.yaml file. Right now I can login but can't logout. Please note that I use sso auth.

Have you any idea about that?

Many thanks in advance and have a nice day!

Reply

Hey Lubna,

Please, take a look at the config/packages/security.yaml configuration, in particular, at the "logout" key there. Most probably you need to specify path key manually for logout option under your firewall there.

If you do so, and don't see that error anymore - great, but what error do you see now? What happens where you logging out?

Cheers!

Reply

Thanks for your reply! after clicking on logout nothing happens at all. I am still connected

Reply

Hey Lubna,

Well, still something should happen :) Were you followed the /logout path in the address bar of your browser? Were you redirected somewhere then? Could you show your logout configuration in your security.yaml? Also, your logout() route you created? Does it have something "throw new \Exception('This should never be reached')" inside or something like this?

Cheers!

Reply

Hey! thanks again.
yep I can find the redirected path while chlicking (mypath/logout) and see it in the address bar. Also, I added the logout route in my defult controller.

Reply
Victor Avatar Victor | SFCASTS | Lubna | posted 1 year ago | edited

Hey Lubna,

Hm, ok... do you have a logout entry point like this?


    /**
     * @Route("/logout", name="app_logout")
     */
    public function logout()
    {
        throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
    }

Also, could you show your security firewall configuration?

Cheers!

Reply

Thanks again! I have the following route in my main controller:


    #[Route('/logout', name: 'logout')]
    public function logoutAction() {
        if (($this->getParameter('cas_logout_target') !== null) && (!empty($this->getParameter('cas_logout_target')))) {
            \phpCAS::logoutWithRedirectService($this->getParameter('cas_logout_target'));
        } else {
            \phpCAS::logout();
        }
    }

And here is my firewall config:


    firewalls:
   dev:
      pattern: ^/(_(profiler|wdt|error)|css|images|js)/
      security: false
   l3_firewall:
      pattern: ^/
      security: true
      cas: true # Activation du CAS
      logout:
           path: /logout
Reply

Hey Lubna,

Thanks for sharing more details! Hm, your config looks ok, but let's try to tweak it a bit... Could you try to rename your firewall name "l3_firewall" -> "main" in this config? Also, make sure you renamed "l3_firewall" with "main" in other parts of your application if you're referencing to it somewhere. Then, (and it's important steps next!), clear the cache, next reload your fixtures that should force logging out the current user, and finally log in again and try to logout. Still can't logout?

Cheers!

Reply

Thanks for your help! It still does not work. But to be honest, as the bundle instruction I shouldn't add the logout path as I did above. If I removed it, seems I have a problem in EasyAdmin. As below:

Twig\Error\
RuntimeError

in C:\Users\laltung1\Desktop\sites-prol3\vendor\easycorp\easyadmin-bundle\src\Resources\views\layout.html.twig (line 88)

Here is the line 88:
{% if null == ea.userMenu.avatarUrl %}

Reply

Hi Lubna !

I'm coming in here to see if I can help :). If I understand things correctly, the problem is that when you click "Log out"... you don't actually get logged out. Is that right?

If so, I think I see the problem. When you go to /logout, the "logout" part of the security system "intercepts" that, logs the user out "in Symfony" and then redirects the user. Normally, this is all you need. However, in your case, you also need to log out with cas. Here are 2 things that explain the weird behavior:

A) Because the "logout" functionality intercepts requests to /logout, your logout() action isn't ever executed. You can try putting. a "die" statement in there: it won't be hit. This means that when you go to /logout, you are not actually being logged out of CAS.
B) When you go to /logout, you ARE logged out of Symfony... but then Symfony redirects, and the "cas authenticator" immediately sees that you are still logged in via CAS and re-authenticates you. In other words, for a moment, after you go to /logout, you ARE logged out. But nearly instantly you are logged back in... and you never notice.

Anyways, here's what you need to do:

1) Remove your logic from the logout() action. This will never be executed. We usually put a giant exception in this method - like Victor showed - https://symfonycasts.com/screencast/easyadminbundle/install#comment-5810159395 - because we know it won't be executed, and if it were executed, we would want to see this clear error (because it means something is wrong).

2) Create a class that implements LogoutSuccessHandlerInterface: https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Security/Http/Logout/LogoutSuccessHandlerInterface.php - inside onLogoutSuccess(), paste your custom cas logout logic (the stuff that was inside of the logout() controller until now). You won't be able to use $this->getParameter(), so you'll need to inject those via the constructor.

3) To use this handler, add this config under your firewall:


security:
    # ...

    firewalls:
        l3_firewall:
            # ...

            logout:
                success_handler: App\Security\CasLogoutSuccessHandler

Where App\Security\CasLogoutSuccessHandler is whatever you called your class :).

I know, a bit complex, but this is how your run code after logging out. in Symfony 6 (once the Cas bundle supports it), the code is a little different: you register a listener to LogoutEvent. But worry about that later - it'll be a small change.

Let me know. if that helps!

Cheers!

1 Reply
Jason A. Avatar
Jason A. Avatar Jason A. | posted 1 year ago

Perhaps this chapter could include a comment about if this is appropriate to use with API Platform, or if for API Platform one should use their react Admin package instead? https://api-platform.com/do...

Reply

Hey Jason A.

That's a good question and I think you can use both libraries in your project, but EasyAdmin won't use your API automatically on its CRUD operations, so, if your API has a different procedure than your admin interface for storing or updating something, then, I think it would be better to rely on the ApiPlatform admin package

Cheers!

Reply
akincer Avatar
akincer Avatar akincer | posted 1 year ago

Yet another tutorial very timely for my own project challenges. Thanks!

Reply

Yo! cool! We are happy to provide relevant courses!

Reply
Cat in space

"Houston: no signs of life"
Start the conversation!

What PHP libraries does this tutorial use?

// composer.json
{
    "require": {
        "php": ">=8.1.0",
        "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
    }
}
userVoice