Symfony: Level up with Services and the Container

Buy Access

Our app is coming to life! Thanks to the Doctrine Course we have a rich data model. And after the course on Configuration, well, using and configuring services is simple.

Now it's time to level-up with those services. These puppies are the backbone of what makes Symfony special & fast. It's also the reason that organizing your code into reusable chunks is so easy. But beyond that, once you understand how services and the service container work, you'll be absolutely unstoppable inside of Symfony. Yep, let's do that:

  • Understanding what a service is
  • Listing, fetching and using existing services
  • Creating your own custom services
  • Registering your service
  • Checking out the (mystical) dumped container
  • Configuration Parameters
  • Dependency Injection Tags

This is the episode where it all starts coming together. Let's go!


Your Guides

Ryan Weaver Leanna Pelham

Questions? Conversation?

  • 2017-02-13 weaverryan

    Hi Christian Eduardo Rivera Tello!

    Awesome, welcome to Symfony! Forms are one of its most powerful... but also challenging pieces! So, it sounds like you have the correct setup. Unfortunately, the UniqueEntity is one validator that suddenly will *not* work when you start using a model class like this :( - there is even an issue about it: https://github.com/symfony/sym....

    This means that you would actually need to create your own custom validation constraint (http://symfony.com/doc/current.... That's not a ton of work, but is definitely an unfortunate extra step. Now, when I recommended that you bind your forms to model classes instead of entities, I *only* really want you to do this when you have a complex form (i.e. a form that doesn't look like your entity). If you have a form that looks like your entity, then it's just easier to bind your form to your entity. Of course, that decision is ultimately up to you! As you can see on the linked issue, some people create model classes for all of their forms :).

    Let me know if this helps! And cheers!

  • 2017-02-12 Christian Eduardo Rivera Tello

    This course is really nice !! . I'm having fun with this course. But I have just a question, or I may say a doubt. In the Symfony Forms: Build, Render & Conquer! section , in the last video, you mentioned something like it's not good idea to bind entities with forms directlly, Instead of this, you suggested, it's better to create brand new classes( models ) to bind your forms, and then transform your models into entities with a little more code. So, I would like to know how I can perform or code this. I tried to do it by myself, however, I found with problems when I needed to validate my model( form model), using uniqueentity(this applies to the entity class ). I couldn't use this constraint in my model (form model). I'm new with symfony. Before I used laravel, and I am kind of aware of working with forms that include more than one entity; in addition, the validations are quite different. How should I do this ?. I'm trying to write good code, and use better practices. Thank you so much in advance.

  • 2016-10-06 samir Patel

    I loved this course! Learned so much new and cool stuff. I especially love the keyboard shortcut for type-hinted constructor arguments. Symfony rocks!!!

  • 2016-06-15 JLChafardet

    I went ahead and added my comment to step 9.1 yet ill drop it here too just in case.

    Hey there weaverryan

    Are there any plans to delve deeper into this topic? (SOA in symfony) ? It was a wonderful topic, yet we just scratched the surface and it felt a VERY important topic to master.

    It seems to me this whole area should be explored and explained a bit more deeply, maybe its just me, but it fascinated me, breathtakingly amazing thing to learn and master, I for one, want more, more in-depth learning of this topic.

  • 2016-05-12 Yoni L.

    YES!! got 5 offense points!! LOOL, thx for this.
    This symfony 3 track is so easy to follow, very clear!!
    Good job KnP guys and girls!!!

    + 5 fan points ;)

  • 2016-04-13 Diego Aguiar

    hahaha, yeah at least it's great news

  • 2016-04-13 Ömür Yanıkoğlu

    You rock! Thank you so much :)

  • 2016-04-13 weaverryan

    Ok, we did :p. This is up now!

  • 2016-04-13 weaverryan

    Today! Sorry for the late reply, but at least it's good news ;).

  • 2016-04-09 Ömür Yanıkoğlu

    Please hurry up :)

  • 2016-04-05 Diego Aguiar

    is there an estimated date for this tutorial ?