I am quite new to Laravel and implemented the service provider for my helper functions using this answer on SO.
It recommended to:
in the register function of your newly generated HelperServiceProvider.php add following code
However, Laravel docs state that register method should only be used to bind things into the container:
As mentioned previously, within the register method, you should only bind things into the service container. You should never attempt to register any event listeners, routes, or any other piece of functionality within the register method.
In my case the app works as it is, with require a statement in the register function, so my question is more about 'best practices' rather than making the code work.
Is this a good/acceptable approach (require statement in a register method), or should I rather move require statement to the boot method?
Recommended approach if you put here only methods (not classes):
composer.jsonmake sure you add this file to
For classes obviously you should use standard PSR-4 autoloading