Download the PHP package rochamarcelo/cake-pimple-di without Composer
On this page you can find all versions of the php package rochamarcelo/cake-pimple-di. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rochamarcelo/cake-pimple-di
More information about rochamarcelo/cake-pimple-di
Files in rochamarcelo/cake-pimple-di
Package cake-pimple-di
Short Description A cakephp plugin for dependency injection based on Pimple library
License MIT
Homepage https://github.com/rochamarcelo/cake-pimple-di
Informations about the package cake-pimple-di
CakePimpleDi - Cake 3 Plugin
A cakephp plugin for dependency injection based on Pimple 3
Requirements
- CakePHP 3.X
- Pimple 3
Installation
To install this plugin you'll only have to add the plugin to your required section of composer.json then load in your bootstrap file.
Bootstrap
Load the plugin as any other plugin:
The bootstrap file must be loaded, to set up all configurations needed
Register dependencies
In your configuration file you can define all the services:
You could also create a provider to reuse some services that you may use in other projects.
-
So create the provider that implements Pimple\ServiceProviderInterface:
- Then, define in your configuration file:
Loading dependency - Basic
Get the shared instance then call method "get"
Loading dependency - With DiTrait
Loading dependency - Injections with InvokeActionTrait
In your configuration file:
In your controller use the InvokeActionTrait
Adding The CakePHP Request and Session Objects to The Container
To get the Session and Request objects added to the container just set the key 'useRequest' with the value boolean true in the configuration.
What is Pimple?
Pimple is a simple PHP Dependency Injection Container, to more information visit: http://pimple.sensiolabs.org