I have a little external library that expose many classes. Into my symfony4 project I would like to declare my class from vendor, as a service with autowire and public. So I have include my library …
Tag: dependency-injection
Php, is it OK to use traits for DI?
consider this example: class MyClass { public function doSomething() { $this->injected->getIt(); } } so far so simple (apart from injected is not injected). So, in full …
Laravel 5 – Method injection
How method injection works in Laravel 5(I mean implementation), can I inject parameters in custom method, not just in controller actions? Answer 1) Read this articles to know more about method injection in laravel 5 http://mattstauffer.co/blog/laravel-5.0-method-injection https://laracasts.com/series/whats-new-in-laravel-5/episodes/2 2) Here is simple implementation of method injection you can also look at function in https://github.com/laravel/framework/blob/master/src/Illuminate/Container/Container.php file for more details 3) You can
Dependency injection on dynamically created objects
I’m using reflection to test if a class has a particular parent class and then returning an instance of it. I want to be able to unit test these instantiated objects but I don’t know if there is any way to use dependency injection in this case. My thought was to use factories to get dependencies. Is the factory pattern
Check if in “dev” mode inside a Controller with Symfony
When using dev mode with a Symfony2.x application, one usually works in locale. Hence, such function does not works as expected (for instance, try to get the current IP under localhost). This could be a problem, e.g. when one try to use such ip-based web service. Hence, I just want to know how to check inside a controller if the