Symfony Tutorial Container Service 2 - Dependency Injection

preview_player
Показать описание
In the next part of the Symfony services tutorial series we are going to look at how we can use Symfony services to make our application more extensible. We are going to create a set of user validation routines that adhere to a PHP interface. This decouple the validator logic from the Symfony controller and our validation routine.
We will be using dependency injection to pass other services into each other

We cover a lot in this tutorial including:
- PHP Interfaces
- Symfony controllers
- Symfony dependency injection
- Using the Symfony service container
- A discussion on good coding practices

Code can be found on github:

If you would like to join me and other web developers on Discord then signup to be a Patron. Other benefits to being a patron include gaining early access to future tutorials, joining a newsletter and getting discounts on programming courses and resources.
You will also be supporting continuation and growth of the channel.

======== RECOMMENDED PROGRAMMING RESOURCES ========

PHP Books:

PHP Hosting from Cloudways:

======== MY PROGRAMMING COURSES ========

======== WEB HOSTING DEALS ========

======== SUBSCRIBE TO THE NEWSLETTER ========

======== FOLLOW ME ========

======== MY TALKS ========

======== SUPPORT THE CHANNEL ========

======== VIDEO SETUP ========

Join the How to code well YouTube channel to get access to premium programming courses, tutorials and member perks
Рекомендации по теме
Комментарии
Автор

Thank you much Peter you saved my life :'(, I learnt a lot of things from you again

abdelhadihabchi
Автор

For all those who don't work and are using Symfony 3.4. You should replace from 'services.yml' the 'app.validation_user' by the following line:
or even

In that version, you MUST set in the interface which implementation you are looking for, NOT to set into the validation which class you want to use.

Cheers and happy coding!

JesusValeraReales
Автор

Stick to PSR-2 (opening braces MUST go on a new line). Especially in a tutorial, there's too much bad/ugly PHP out there already. Other than that it's a good tutorial to explain the basics of DI. I was searching for more info about the container as I get a bit confused with it while unit testing as there are times you don't want to mock and stuff.

midimojo