Download the PHP package sitepoint/container without Composer
On this page you can find all versions of the php package sitepoint/container. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sitepoint/container
More information about sitepoint/container
Files in sitepoint/container
Package container
Short Description A simple, easy to follow PHP dependency injection container
License MIT
Homepage https://github.com/sitepoint/Container
Informations about the package container
Container
A simple, easy to follow PHP dependency injection container. Designed to be forked, modified, extended and hacked.
How to Use
Although it isn't required to do so, a good practice is to split up the configuration for our container. In this example we'll use three files to create our container for the Monolog component.
Another good practice is to use class and interface paths as service names. This provides a stricter naming convention that gives us more information about the services.
In the service definitions file, we define three services. All of the services require constructor injection arguments. Some of these arguments are imported from the container parameters and some are defined directly. The logger service also requires two calls to the pushHandler
method, each with a different handler service imported.
The parameters definitions file just returns an array of values. These are defined as an N-dimensional array, but they are accessed through references using the notation: 'logger.file'
or 'logger.mail.to_address'
.
The container file just extracts the service and parameter definitions and passes them to the Container
class constructor.
Now we can obtain the container in our app and use the logger service.
Authors
Change Log
This project maintains a change log file
License
The MIT License (MIT). Please see LICENSE for more information.