naoki-tsuchiya / ray-di-psr-container
An implementation of PSR-11 container for Ray.Di
v0.1.0
2025-01-05 16:45 UTC
Requires
- php: ~8.0 || ~8.1 || ~8.2 || ~8.3 || ~8.4
- psr/container: ^2.0
- ray/di: ^2.18
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.8
- phpunit/phpunit: ^9.6.10
- ray/compiler: ^1.10
Provides
This package is auto-updated.
Last update: 2025-01-05 16:57:56 UTC
README
naoki-tsuchiya/ray-di-psr-container
is a package that implements the PSR-11 (ContainerInterface) and integrates seamlessly with Ray.DI.
This library leverages the dependency injection capabilities of Ray.DI while providing a PSR-11 compatible interface.
Installation
composer require naoki-tsuchiya/ray-di-psr-container
Usage
<?php use NaokiTsuchiya\RayDiPsrContainer\PsrContainer; use NaokiTsuchiya\RayDiPsrContainer\IdentityStringGenerator; use Ray\Di\Injector; require_once 'vendor/autoload.php'; // Create an Injector $injector = new Injector(new FooModule()); // Create a Psr11Injector $container = new PsrContainer($injector); // Retrieve an instance $instance = $container->get(FooInterface::class); // Check if a binding exists $isAvailable = $container->has(FooInterface::class); // Using get() method with IdentityStringGenerator // Compatible with Injector's getInstance method. $namedInstance = $container->get(IdentityStringGenerator::generate(Foo::class, NAME::class));
Development
Install
composer install
Available Commands
composer test // Run unit test
composer tests // Test and quality checks
composer cs // Run coding style check
composer cs-fix // Fix the coding style
composer sa // Run static analysis tools
composer run-script --list // List all available commands