5 Tips for the Laravel Service Container

Tutorials

June 19th, 2021

5 Tips for the Laravel Service Container

Mohamed Said published a new video on the Laravel Youtube channel outlining 5 tips for dealing with Laravel's Service Container:

To sum up the tips:

  • Avoid executing DB queries in service providers
  • Avoid reading session data in service providers
  • Avoid resolving bindings in the register method
  • Scoped instances vs. Singletons
  • Use rebinding events to refresh dependencies

Filed in:

Eric L. Barnes

Eric is the creator of Laravel News and has been covering Laravel since 2012.