Symfony Services 101


In this video we will take an introductory look at what a Symfony Service is, and how we can use Services inside our Symfony applications.

We'll start with discussing what a Service is with regards to Symfony, and then we will move on to actually coding our very first Service. It's surprisingly simple and straightforward, another classic case of scary sounding Symfony stuff, and you'll be an expert in creating and using your own Services in no time.

We're going to be using the new Symfony Best Practices bundle structure for this one, so if you're unsure what that's all about then do check out the link. Essentially it means our Service itself will live in the src/AppBundle folder, whereas the Service definition (the thing Symfony uses to 'know' about our Service) will live in the app/config/services.yml file.

We'll finish up this introduction to Symfony Services by using Dependency Injection to inject a parameter from the parameters.yml file. This sounds scary and complicated, but as you'll see in the video, it's a piece of cake.

And with that done, you'll have gained an understanding of what Symfony Services are and how we can use them in our projects.

Code For This Video

Get the code for this video.

Episodes