sauber-php / container
The Container component for the Sauber PHP framework
Fund package maintenance!
juststeveking
Requires
- php: ^8.1
- league/container: ^4.2
- psr/container: ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.8
- pestphp/pest: ^1.21
- phpstan/phpstan: ^1.7
This package is not auto-updated.
Last update: 2024-12-21 22:58:46 UTC
README
Container
This is the repository for the DI Container used in the Sauber PHP Framework.
Installation
You should not need to install this package, as it comes pre-installed with the Sauber PHP Framework, however if you want to use this outside of the framework please use composer:
composer require sauber-php/container
Usage
To use the container, you can manually add definitions:
$container = new Container( definitions: [ UserRepositoryInterface::class => UserRepository::class, ], ); $repository = $container->get( id: UserRepositoryInterface::class, );
To make a new container with injected callables:
$injectors = [ UserRepositoryInterface::class => UserRepository::class, ]; $container = Container::make( injectors: $injectors, ); $repository = $container->get( id: UserRepositoryInterface::class, );
Testing
To run the tests:
./vendor/bin/pest
Static Analysis
To check the static analysis:
./vendor/bin/phpstan analyse
Changelog
Please see the Changelog for more information on what has changed recently.