alexeymezenin / laravel-best-practices

Laravel best practices
11.24k stars 2.37k forks source link

Clarify "Use IoC container or facades instead of new Class" best practice section of README #145

Closed haejinjo closed 1 year ago

haejinjo commented 2 years ago

Simple update to README. Reasoning is as follows:

  1. The "IoC (Inversion of Control) Container" term (from Laravel 4.2) has been deprecated in favor of "Service Container" (current Laravel 9.x). Rather than replace it entirely, I've added Service Container for clarity.

  2. This section demos dependency injection (i.e. the IoC part) but does not demo how Facades can be better used than classes. I'm pretty new to Laravel so not sure what a good example of the Facade strategy would be, but one should either be added or we should omit the Facade suggestion from this section's header. I've opted to do the latter for now and start that discussion.