Skip to content

Commit

Permalink
Added "considerations" in "conclusion" section
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalheidmann-check24 committed Mar 19, 2024
1 parent df5ee0f commit 086c8cb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions content/posts/dependency-injection-from-scratch.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,17 @@ Thanks to our new dependency injection, we are now able to
- leave our global variable scope clean as our only entry point is our `ServiceContainer` which encapsulates everything
else — still while not knowing anything over any service it manages

Things to consider

- DI systems add another layer of complexity which makes them harder to debug
- we request dependencies on runtime and not statically.
You can overcome parts of it with static analyzers like PHPStan in PHP
that [know PSR-11 containers](https://github.com/bnf/phpstan-psr-container) but factories etc. all run dynamically.
The same goes for code suggestions in your IDE.
Therefore,
make sure that you do not use the dependency injection directly in your code
but let it handle everything and work with contracts aka interfaces.

## So what's next?

In a future blog post, I want to elaborate on the idea and introduce some advanced features like an `alias` system,
Expand Down

0 comments on commit 086c8cb

Please sign in to comment.