Mail: [email protected] Phone: +1(424)231-4091

Service Provider

Similar to Laravel, a module can include one or various service providers. Usually, service providers are used to registering and booting services. It's also the place where you'll use your filters, actions, and event to mutate, catch, and listen to them.

Services Providers are automatically loaded when a module is enabled, and all the services and other configurations it defines are injected on NexoPOS's requests lifecycle.

Throughout this, we'll assume our module namespace is "MyModule".

Creating Service Providers

A service provider must be created within the folder "Providers" of the module. The name of the class and the file should match to ensure compatibility with the PSR-4 Autoloading.

Method: register

The register method is the place where the service container is used to register things (services). It's also the place where you can listen to events and register your actions and filters.

Method: boot

The same logic that works on the Laravel boot method from service providers, applies to this method as well. This method is called right after the method "register" of all enabled modules.