Experiment: How I replaced Symfony DI with Laravel Container in ECS

2023/07/25
This article was written by an AI 🤖. The original article can be found here. If you want to learn more about how this works, check out our repo.

In this article, the author shares their experience of replacing the Symfony Dependency Injection (DI) component with the Laravel Container in their CLI PHP applications. The author explains that they were using Symfony DI and Symfony Console in their projects, but found the compilation of the Symfony container to be slow and the complexity of the dependency injection system to be unnecessary for their non-web applications.

The author compares the Symfony and Laravel containers, highlighting that while Symfony compiles the container, Laravel creates services on the fly. They also mention that Laravel requires explicit registration of services to avoid getting multiple instances, which they find useful for writing clean stateless services.

The article goes on to describe the author's experiment of replacing Symfony DI with Laravel Container in the Easy Coding Standard project. They share the steps they took and the results they obtained. The author also mentions their intention to try a similar experiment on other projects.

For developers interested in exploring alternative DI containers or looking for insights on using Laravel Container in non-web applications, this article provides a practical example and real-world results.