0

I need to create a command and a controller function that both execute the same code and I'm reading that the best way to do it is to create service provider and then call that from both the command and the controller.

Problem is I can't clearly figure out what exactly a service provider does and what bindings are used for. Perhaps someone can explain to me how service providers and bindings are used briefly to give me an idea on how I can accomplish this.

Envious
  • 478
  • 1
  • 8
  • 28
  • 2
    You don't need a service provider for this. You only need a class that is accessible from both your controller and command. You can put this class anywhere it can be autoloaded (via PSR 0/4, classmap, etc.). – Aken Roberts Feb 27 '15 at 22:34
  • You can read more on service providers directly in the [Laravel Documentation](http://laravel.com/docs/4.2/ioc). You could also check out [this answer](http://stackoverflow.com/a/20440143/351330). – Bogdan Feb 27 '15 at 23:07

0 Answers0