BrisPHP / meetups

A place to request and propose talks for the BrisPHP meetup community.
https://brisphp.com
25 stars 0 forks source link

Building the Laravel service container from scratch #51

Closed jessarcher closed 3 years ago

jessarcher commented 3 years ago

I've been fascinated by Laravel's service container and how useful it is for quite a while now. I enjoy teaching others about it, including most recently in an episode of my podcast with JMac (of Laravel Shift fame). In that episode we talked about how a primitive service container implementation could work, and I've often thought it would be interesting to actually build a basic implementation of a service container, roughly following Laravel's API, to demonstrate and demystify it for visual/practical learners.

In 2021 this came to fruition when built a service container from scratch live at the Brisbane Laravel Meetup in January and it seems to have been very popular on the live stream and subsequent recording. I've been asked whether I would give the talk for BrisPHP and I would be happy to, so long as the audience is likely not to have already seen the talk.

Basically I start with a pre-written test suite in a vanilla PHP project, and by using TDD I build out all of the features one at a time exploring what the container can do and how it works behind the scenes. I cover basic binding and IoC, mocking, the singleton pattern, recursive dependency injection, and facades.

ndench commented 3 years ago

This sounds like a great talk @jessarcher! I think that most of the audience will be different so that should be fine. We'll lock it in for the next meetup on February 23.

ndench commented 3 years ago

Thanks for the talk at the last meetup @jessarcher! If you have any resources (slides, a github repo, etc) could you post a link here please?

jessarcher commented 3 years ago

Sure! The GitHub repo is https://github.com/jessarcher/service-container-from-scratch/ and there were no slides as it was all in Vim, but I think it was recorded if we have a link to that?

ndench commented 3 years ago

Ah yes, right you are. Here's the YouTube video.