Flag of Ukraine
SymfonyCasts stands united with the people of Ukraine
This tutorial has a new version, check it out!

EasyAdminBundle v1 for an Amazing Admin Interface

2:26:29

What you'll be learning

This tutorial is built on an older version of Symfony & EasyAdminBundle. Many of the concepts are the same, but you can expect major differences in newer versions.
// composer.json
{
    "require": {
        "php": ">=5.5.9",
        "symfony/symfony": "3.3.*", // v3.3.18
        "doctrine/orm": "^2.5", // v2.7.2
        "doctrine/doctrine-bundle": "^1.6", // 1.10.3
        "doctrine/doctrine-cache-bundle": "^1.2", // 1.3.5
        "symfony/swiftmailer-bundle": "^2.3", // v2.6.7
        "symfony/monolog-bundle": "^2.8", // v2.12.1
        "symfony/polyfill-apcu": "^1.0", // v1.17.0
        "sensio/distribution-bundle": "^5.0", // v5.0.25
        "sensio/framework-extra-bundle": "^3.0.2", // v3.0.29
        "incenteev/composer-parameter-handler": "^2.0", // v2.1.4
        "knplabs/knp-markdown-bundle": "^1.4", // 1.7.1
        "doctrine/doctrine-migrations-bundle": "^1.1", // v1.3.2
        "stof/doctrine-extensions-bundle": "^1.2", // v1.3.0
        "composer/package-versions-deprecated": "^1.11", // 1.11.99
        "javiereguiluz/easyadmin-bundle": "^1.16" // v1.17.21
    },
    "require-dev": {
        "sensio/generator-bundle": "^3.0", // v3.1.7
        "symfony/phpunit-bridge": "^3.0", // v3.4.40
        "nelmio/alice": "^2.1", // v2.3.5
        "doctrine/doctrine-fixtures-bundle": "^2.3" // v2.4.1
    }
}
// composer.json
{
    "require": {
        "php": ">=5.5.9",
        "symfony/symfony": "3.3.*", // v3.3.18
        "doctrine/orm": "^2.5", // v2.7.2
        "doctrine/doctrine-bundle": "^1.6", // 1.10.3
        "doctrine/doctrine-cache-bundle": "^1.2", // 1.3.5
        "symfony/swiftmailer-bundle": "^2.3", // v2.6.7
        "symfony/monolog-bundle": "^2.8", // v2.12.1
        "symfony/polyfill-apcu": "^1.0", // v1.17.0
        "sensio/distribution-bundle": "^5.0", // v5.0.25
        "sensio/framework-extra-bundle": "^3.0.2", // v3.0.29
        "incenteev/composer-parameter-handler": "^2.0", // v2.1.4
        "knplabs/knp-markdown-bundle": "^1.4", // 1.7.1
        "doctrine/doctrine-migrations-bundle": "^1.1", // v1.3.2
        "stof/doctrine-extensions-bundle": "^1.2", // v1.3.0
        "composer/package-versions-deprecated": "^1.11", // 1.11.99
        "javiereguiluz/easyadmin-bundle": "^1.16" // v1.17.21
    },
    "require-dev": {
        "sensio/generator-bundle": "^3.0", // v3.1.7
        "symfony/phpunit-bridge": "^3.0", // v3.4.40
        "nelmio/alice": "^2.1", // v2.3.5
        "doctrine/doctrine-fixtures-bundle": "^2.3" // v2.4.1
    }
}

Time to build an admin interface for your amazing site! You want it to be great! Powerful! Beautiful! Awe-inspiring! ... and you need to be able to finish it in a just a few hours!

Lucky you.

EasyAdminBundle allows you to spin up fully-featured admin interfaces with almost zero work, then customize them as far as you need to go. It's not only beautiful, powerful and awe-inspiring, it's fun to use. In this tutorial, we'll learn how to:

  • Install and Configure the bundle
  • Customize everything: what properties to display, how they render, help messages, sorting, filters... and more!
  • Override templates... at many different levels
  • Take control of your forms
  • Using autocompletion
  • Adding custom actions (and removing others)
  • Updating and configuring the menu (like adding a link to kitten videos!)
  • Hooking into events to do things before or after an entity is saved
  • Adding custom CSS/JS behaviors to the page
  • ... and more

Join us! This is a bundle you will not regret using!


Your Guides

Andrew Marcinkevičius Ryan Weaver

Buy Access

Join the Conversation?

54
Login or Register to join the conversation
Default user avatar
Default user avatar Zuhayer Tahir | posted 4 years ago

Any plan for a course on Sonata Admin?
Sonata is a Giant Dragon which needs to be slayed tutorialically by Shriek(s) or Princess Fiona(s) :)

6 Reply

Zuhayer Tahir Haha, "slayed tutorialically" <= yep, that's my favorite new phrase :).

Right now, we have no plans on covering this. I don't have extensive experience with Sonata, but everyone says the same thing: big huge, complex bundle. I'd rather everyone use EasyAdminBundle and enjoy themselves. If there are some things that Sonata can do that EasyAdminBundle can't, hopefully those could be added to EasyAdminBundle or extracted into a smaller new bundle independent of Sonata. But, maybe I'm underestimating Sonata and it's got some value. If I can be convinced, then we might do it - it is still one of the most used bundles out there!

Cheers!

7 Reply
Default user avatar

Yhm, after months of working with Sonata Admin (our client loved it, mostly because it covered many features out of the box - and only because of this), I can't actually recommend this huge set of bundles, unless you don't plan to change much. Wanting to do some more serious and deeper changes than available out of the box will take from you a lot of time, when you'll be fighting tones of bugs and bad code of the Sonata. It tries to cover too many things, simply stating.

On the other hand, I don't find Sonata Admin basics actually tougher than Easy Admin one's, maybe bit more config is needed, but everything is pretty logical there, except you configure everything rather through a seperate classes through plane PHP code (which gives you actually more possibilities than when everything is in config file). The entity admins are like extended FormType Symfony classes.

2 Reply

Hey forsberg,

Thanks for sharing your thoughts about SonataAdmin! Actually, I'm mostly agree with your thoughts. Well, most of the things that EasyAdminBundle allows to configure in yaml are simple, but it also allows you to extends a lot of features with PHP code. Anyway, we agree that SonataBundle is worth to be covered in our screencasts, and yes, we have it close in our idea pool, but its release won't be soon, at least, because we already have EasyAdminBundle :) But in the future we'll be glad to add a tutorial about it too. But to be honest, there're a lot of cool and interesting things we want to cover first before SonataBundle ;)

Cheers!

1 Reply
Luis M. Avatar

Sonata Admin would be awesome! Think about it, weaverryan .

1 Reply
Default user avatar

thank u sooo much

4 Reply

Can you please add to your plans :
+ How to make a landing page (dashboard) for easyadmin because currently, EasyAdmin doesn't have a real backend homepage. When you access the backend, you are redirected to the list action of the first configured entity .
+ Export data into csv file .

2 Reply

Great suggestions Ahmedbhs! This tutorial is just about ready to be recorded, but I'll see if these can fit in :).

Cheers!

2 Reply
Mixa S. Avatar

Will it cover adding not single image to the record but kind of multi upload gallery?

Reply

Hey Lopoi Popoi!

Unfortunately, it won't cover this... mostly because I don't believe that EasyAdminBundle has any feature related to this. Aka, you would need to do it yourself. I think SonataAdminBundle has something like this... but that's a totally different library (which I currently recommend cautiously, because historically, it is quite complex).

Cheers!

Reply

Thank you weaverryan for replaying i really appreciate your work, please at least the first point about the landing page(dashboard) , it's really importing .

Reply
Default user avatar

Both would be a great additions to tutorial Ahmedbhs thanks

CVS export is clear. Could you give some details about what you would like to see in a dashboard page?

1 Reply

It's about having a real homepage for our backend ,I dont know how to implement the solution with easyadmin ,because everything should be configured . Anyway, all we need is an empty homepage.html.twig template, where we will render some informations from our controller
maybe some charts, widgets and advanced stuff that we can see in the admin/backend templates.

Thank you for taking serious my proposition.

1 Reply
Default user avatar

Cool. We will discuss this with Ryan to see that can be done about it.

1 Reply
Default user avatar

Waiting impatiently for the next part of the course ...
You have not posted anything since Friday...

1 Reply

Hey zboina ,

We didn't work due to 4th of July. We're going to upload more videos today, so today... or maybe tomorrow you will see it.

Cheers!

Reply
Selim B. Avatar
Selim B. Avatar Selim B. | posted 1 year ago

Is there any tutorial coming soon for the EasyAdmin v3. I think we would all appreciate a good guide on that, by you guys :)

Reply

Hey Alban,

Thank you for your interest in SymfonyCasts tutorials! Yes, we're planning a new tutorial for EasyAdminBundle v3 soon, but it's still a top-secret, so shhhhh ;) Unfortunately, we still don't have any estimations for this, but watch closer for our upcoming tutorials list here to get more updates about it: https://symfonycasts.com/co...

Cheers!

Reply
Yacine R. Avatar
Yacine R. Avatar Yacine R. | posted 1 year ago

Did you got any clues for the updated tutorial release ? i cant wait for the EasyAdmin 3 tutorial for Sf 5 , this bundle feel so great to use :)

Reply

Hey Yacine Rerbal

There will be a new course about EasyAdmin, but I can't say you any exact eta on it. Sorry for that =) Keep watching for any updates!

Cheers!

2 Reply
Yacine R. Avatar

there is no problem with that, good luck guys , i assume that I could be just too exited about all of the goods stuff comin :) cheers!

1 Reply

Is EasyAdmin compatible with Symfony 5.1.3? I am working now on a project in symfony 5 and I need to decide what to use for the admin part. Seems like sonata is not compatible with symfony, how about easyadmin?
Thank you

Reply

Nevermind, I just found this https://symfony.com/blog/ea...
This raise another question, is this course still good for EasyAdmin 3? Thanks

Reply

Hey Alex Burca!

Nice find :). So yes, it is compat with Symfony 5 (as you discovered) but no, this tutorial is not going to fit well with EasyAdmin 3. We're currently working on an update, but it's still in development. Many of the concepts will likely be the same, but they changed the entire way of doing config from YAML to PHP (which actually, I really like).

Sorry I can't give a better answer, but I hope you'll have a good time with EasyAdmin :).

Cheers!

2 Reply
Roland W. Avatar
Roland W. Avatar Roland W. | posted 2 years ago

Does EasyAdmin support entity classes with constructor arguments for properties that are meant to be not nullable? EasyAdmin instantiates the entity class even if you click the "Add <myentityclass>" button, right? Unfortunatelly this results in an "Too few arguments to function __construct()" error. Do you have a solution for this problem?

Reply

Hey mostwanted

Yep, there is an easy way to do that. You only have to override the createNewEntity() method from the base controller. You can read the discussion about it in this PR https://github.com/EasyCorp...

Cheers!

Reply
Shaun T. Avatar
Shaun T. Avatar Shaun T. | posted 3 years ago

Hi guys, I've installed EasyAdminBundle but I am seeing the old theme, can anyone tell me how I can update it to the latest theme please?

Reply

Hey Shaun,

What theme do you mean? What exactly version of EasyAdminBundle did you install? Probably in the newest version of this bundle the styles were slightly changed, we use v1.16.9 in this screencast.

Cheers!

Reply
sws Avatar

Hi, is it possible with easy admin bundle to use dynamic choiceType in an embedded form ?

Reply

Hey Ben,

I think it should work, because EasyAdmin forms is based on Symfony Form system. Also, EasyAdminBundle has its own events based on Symfony events: https://symfony.com/doc/cur... .

I hope this helps.

Cheers!

Reply
David R. Avatar
David R. Avatar David R. | posted 3 years ago

Is there something similar to the "page composer" functionnality of Sonata but using Easy Admin ? Easy Admin is actually preferred over Sonata but i can't find in Easy Admin anything close to this way for an admin to add content blocks inside a page in a a flexible way.
By flexible way i mean: let the admin, inside the page, add "as many" blocks as he wants, each one with a type. And the developer can add new block type (for example a slider, an image, a block of text displayed with a special style etc), so that the admin can compose his page with a great flexibility.

Reply

Hey David Robert!

Ah! The answer is for sure *no*. For better or worse, EasyAdminBundle is a simpler version of Sonata. WAY easier to work with, but it has far fewer features than Sonata. In fact, I don't know Sonata well, but I think the feature you're talking about isn't related to their admin bundle, but another set of features that is under the Sonata name - https://sonata-project.org/....

That's probably not the answer you were hoping for, but I hope it clarifies!

Cheers!

1 Reply
David R. Avatar

Hello @weaverryan,

Yeah that what i thought, but i was hoping that someone somewhere developed a bundle which can be used with Easy Admin in order to have this feature (which is indeed not part of Sonata Admin bundle, but inside the Sonata page bundle) :)

Anyway, thanks for the answer and keep up the great work!

Reply
Gautam Avatar

I was just wondering how we can add mass action. For example
a. Checkbox to select list (visible select /un-select and all select/un-select ) - then export
b. Same checkbox to select list and then perform mass action like change value of is published
(will take my entity scenario order and order Items , mass action to generate shipping AWB number which depends on third party service)

Reply

Hey gautam keshri

You will have to create a custom action for doing all the "real" work, but, in your entity view, you will have to tweak its template in order to show that list and a button (or something) to submit the action

Custom actions: https://symfony.com/doc/mas...
And if you need an example of how to override a template, check this video: https://knpuniversity.com/s...

Cheers!

Reply
Default user avatar
Default user avatar Patrick Savelberg | posted 4 years ago

Form Collections would be awesome

Reply

Hey Patrick Savelberg

Between the http://knpuniversity.com/sc... tutorial and this one, we should have that covered... at least mostly ;). At some point, the collection stuff is so complex, building a custom, AJAX-ified setup might be better. But, all depends on your situation!

Cheers!

1 Reply
Default user avatar
Default user avatar Riccardo Previti | posted 4 years ago

I'm trying to use EasyAdminBundle together with FOSUserBundle. When admin-editing a user, date selection form only displays 5 years in the past. This is unsuitable for the birthDate field. How can I extend it?

Reply

Hey Riccardo Previti

There is a way to pass options to the Form types by using the field *type_options*, you can use it something like this (copied from the docs):


easy_admin:
entities:
Customer:
class: AppBundle\Entity\Customer
new:
fields:
- { property: 'name', icon: 'user' }
- { property: 'email', css_class: 'input-large', type_options: { required: false } }

you can read more info about it here https://github.com/javiereg...

Cheers!

2 Reply
Default user avatar

Hello!
Very good idea with EasyAdmin course!
When will the course be available?

Regards!

Reply

Woohoo! Hopefully we'll start releasing next week - the first 6 chapters are already in final editing :)

Reply
Default user avatar
Default user avatar Mykyta Popov | posted 4 years ago

Im sorry, but dont know where to ask the question.
My problem is with css and js files.
I have made the installation step by step like here http://symfony.com/doc/curr...
After bin/console assets:install --symlink command everything looks ok but chrome console is shows errors that files are not found GET /bundles/easyadmin/javascript/easyadmin-all.min.js GET /bundles/easyadmin/stylesheet/easyadmin-all.min.css GET /http://knp2.local/bundles/easyadmin/javascript/easyadmin-all.min.js
I have checked and they are there...
Could you explain me what I have miss?

Reply

Hey Mykyta Popov

That's odd, can you try clearing your cache "bin/console cache:clear" and also browser's cache too "CTRL + F5" (in chrome)
If it doesn't work, let us know

Have a nice day!

1 Reply
Default user avatar
Default user avatar Mykyta Popov | MolloKhan | posted 4 years ago

unfortunately cache:clear and ctrl+f5 does not work for me((

Reply

Hey Mykyta,

Are you on Windows? What version of Windows do you have? Try do not use --symlink, i.e. run just "php bin/console assets:install", but first of all clear the both prod and dev cache. Does it fix your problem? Are you sure you have "web/bundles/easyadmin/stylesheet/easyadmin-all.min.css" file exist in this path?

Cheers!

Reply
Default user avatar
Default user avatar Mykyta Popov | victor | posted 4 years ago

I'm working on debian with homestead.
My problem is gone, but I don't know why)))))
I just have try to run server from the console bin/console server:start and admin styles were found
then I tried to run vagrant server again and every thing became ok...
I didn't touch cache or some thing else.. magic...

Reply

Hm, probably you cleared the cache as Diego had suggested and then ran assets:install again which did the trick. Anyway, glad it works! ;)

Cheers!

Reply
Fox C. Avatar

Hi Ryan, thanks for the great videos :-)

Question: how do you generate a route (on a entity list page) to a easy admin menu item using the router service?
>> in particular to a page that has DQL (as this isn't simply specifying the entity and list|form type > I'd like to generate a URL to a menu item that uses DQL)

(Searching I've done: I CTRL-F'ed "router" and "generate" on all your tutorial pages and googled this but wasn't able to find an answer - I also looked at the AdminController.php > indexAction() from easy admin, but it seems to only accept "entity" and "action" - not allowing to specifying a DQL page.)

Any help appreciated :-)

Reply
Fox C. Avatar

I should mention this also; related to DQL

Can you pass in a parameter to be used in a DQL filter?

I thought this would be a typical use case of easy admin - and likely a useful video (but not currently covered by KNPU training). As an example: display a list of photo albums that provide a link to a DQL filtered page that show a list of only the photos in that album.

Reply
Fox C. Avatar

UPDATE: it looks like this would involve defining a custom controller which would handle the query and then use the same twig layout and list twig files. The custom query controller would need to handle pagination...

Reply
Cat in space

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