Download the PHP package juliangut/slim-php-di without Composer
On this page you can find all versions of the php package juliangut/slim-php-di. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download juliangut/slim-php-di
More information about juliangut/slim-php-di
Files in juliangut/slim-php-di
Package slim-php-di
Short Description Slim Framework PHP-DI container integration
License BSD-3-Clause
Homepage http://github.com/juliangut/slim-php-di
Informations about the package slim-php-di
Slim Framework PHP-DI container integration
PHP-DI dependency injection container integration for Slim framework.
Installation
Best way to install is using Composer:
Then require_once the autoload file:
Usage
Use Jgut\Slim\PHPDI\ContainerBuilder
to create PHP-DI container and extract Slim's App from it
In order to register services in the container it's way better to do it in definition files
Configuration
PHP-DI settings
useAutoWiring
whether to use auto wiring (true by default)useAttributes
whether to use attributes (false by default)useDefinitionCache
, whether to use definition cache (false by default)wrapContainer
wrapping container (none by default)proxiesPath
path where PHP-DI creates its proxy files (none by default)compilationPath
path where PHP-DI creates its compiled container (none by default)
Refer to PHP-DI documentation to learn more about container configurations
Additional settings
definitions
an array of paths to definition files/directories or arrays of definitions. Definitions are loaded in order of appearancecontainerClass
container class used on the build. Must implement\Psr\Container\ContainerInterface
,\DI\FactoryInterface
and\DI\InvokerInterface
(\Jgut\Slim\PHPDI\Container
by default)
Container array access shorthand
Default \Jgut\Slim\PHPDI\Container
container allows shorthand array access by concatenating array keys with dots. If any key in the chain is not defined, normal Psr\Container\NotFoundExceptionInterface
exception is thrown
Notice
Be careful though not to shadow any array key by using dots in keys themselves
The easiest way to avoid this from ever happening is by NOT using dots in array keys
Invocation strategy
By default, slim-php-di sets a custom invocation strategy that employs PHP-DI's Invoker to fulfill callable parameters, it lets you do things like this
If you prefer default Slim's Slim\Handlers\Strategies\RequestResponse
strategy or any other of your choosing you only have to set it in a definition file
Console command
List container definitions
List defined container definitions supporting searching
Migration from 3.x
- PHP minimum required version is PHP 8.0
- Moved to PHP-DI 7. Annotations have been removed, use Attributes
Contributing
Found a bug or have a feature request? Please open a new issue. Have a look at existing issues before.
See file CONTRIBUTING.md
License
See file LICENSE included with the source code for a copy of the license terms.
All versions of slim-php-di with dependencies
ext-json Version *
ext-mbstring Version *
php-di/php-di Version ^7.0.1
psr/container Version ^1.0|^2.0
slim/slim Version ^4.8