I did see the SO warning that The question you're asking appears subjective and is likely to be closed
when I posted this.
I continued posting it because it is from an authoritative source... which is the actual Laravel documentation.
I am asking what they mean and what examples can be given for the warning that is given(see below).
I was reading the documentation on service providers and found the following:
Writing Service Providers
All service providers extend the Illuminate\Support\ServiceProvider class. Most service providers contain a register and a boot method. 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.
No example is given and I do not quite get what they mean by that statement.
The answer may have been answered elsewhere, in which case I apologise as I didnt find it.
What do they mean? Could you give an example of what not to do?
After all of the providers have been registered, they are “booted”.
A common mistake when using service providers is attempting to use the services provided by another provider in the register method. Since, within the register method, we have no guarantee all other providers have been loaded, the service you are trying to use may not be available yet.
So, service provider code that uses other services should always live in the boot method. The register method should only be used for, you guessed it, registering services with the container. Within the boot method, you may do whatever you like: register event listeners, include a routes file, register filters.