Download the PHP package rafaeltovar/php-service-manager without Composer
On this page you can find all versions of the php package rafaeltovar/php-service-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rafaeltovar/php-service-manager
More information about rafaeltovar/php-service-manager
Files in rafaeltovar/php-service-manager
Package php-service-manager
Short Description Simple, light, minimum service manager and dependency injection for PHP.
License MIT
Homepage https://github.com/rafaeltovar/php-service-manager
Informations about the package php-service-manager
ServiceManager for PHP
Simple, light, minimum service manager and dependency injection for PHP.
Installation
Composer
Execute:
Features
- [x] Dependency injection
- [x] Service container
- [x] Providers
- [x] Singleton strategy
- [x] Initialized only if service is called
- [x] Alias
Documentation
Service container
The service container is the main service controller for manage the service queue.
Service Providers
This is my service.
This is my service provider.
Passing custom arguments to the provider
Sometimes We need pass some arguments to the provider for initialize the service, like the config or logger, for example. In this case we need implements \ServiceManager\ServiceProviderArgumentsInterface
.
MyCustomArguments
will have the arguments it needs.
My example service with argument:
My example service provider:
Getting a service
Dependency injection
Custom builders
Sometime our controller need other controller or data, not a service. In those cases we can create a custom constructor implements ControllerBuilderCreateInterface
.
Now we can build our controller. The service container will call to create
method if implements ControllerBuilderCreateInterface
.
Alias
Other times we need to work with interfaces, we can use aliases to obtain the services that implement these interfaces.
Now we can build our controller with interface dependency.