0

Or in actuality, how to tell if a certain technique has became a standard in certain language / framework?

As I understood from my readings so far, PHP supports DI in PSR-11 while Laravel uses it out of the box...

But does this mean DI is a standard for PHP and Laravel or they just helped you to do it right, should you choose to use DI?

1
  • 1
    If you need DI, use DI. Otherwise, don’t. Commented Sep 7, 2018 at 6:35

1 Answer 1

2

Or in actuality, how to tell if a certain technique has became a standard in certain language / framework?

Closest thing to a standard in PHP is PSR. Apart from that, all frameworks, libraries and individual programmers have different approaches.

As I understood from my readings so far, PHP supports DI in PSR-11 while Laravel uses it out of the box...

You have misunderstood. Dependency Injection is something that you as a programmer use to properly structure an application, that generally improves testability, readability and maintainability of your code. Any language that supports passing arguments to a function supports dependency injection.

Laravel... actually is generally the inverse of using dependency injection, even though they might advertise featuring a dependency injection container, that is used to instantiate your types. Laravel depends, as far as I know, on the global state for most actions, calls static functions from anywhere, which is the exact contrary of injecting dependencies into a class.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.