Download the PHP package ray/ray-di-for-laravel without Composer
On this page you can find all versions of the php package ray/ray-di-for-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package ray-di-for-laravel
Ray.Di for Laravel
DI+AOP, done the right way
English | Japanese
Installation
`
Use
Copy the module that describes the binding, the context, and the directory where the generated files will be stored.
Change the following lines in bootstrap/app.php
.
Add the Ray\RayDiForLaravel\Attribute\Injectable
Attribute to classes or interfaces you want to resolve by Ray.Di.
This class will be resolved by Ray.Di.
This one will be resolved by the existing Laravel service container.
Context
The RayDi/Context/ContextProvider
generates a context class for the application runtime context.
Specify the module and cache in the context class and the context-specific injector will be selected.
Ray.Di for Laravel provides the following built-in contexts.
RayDi/Context/ProductionContext
RayDi/Context/LocalContext
RayDi/Context/TestingContext.php
Cache
In the RayDi/Context/ProductionContext
, the injector is cached if the apcu extension is enabled.
Custom context
You may need your own context.
Implement a custom context with reference to the built-in context and use it in RayDi/Context/ContextProvider
.
Overriding Modules
When running tests, you may want to change the binding depending on the test case.
Use Ray\RayDiForLaravel\Testing\OverrideModule
in your test class and call $this->overrideModule
as shown below.
Performance
By installing the DiCompileModule, An optimized injector is used and dependency errors are reported at compile time, not at runtime.
For RayDi/ProductionModule
corresponding to RayDi/Context/ProductionContext
, DiCompileModule
is already installed.
Demo
See hello-ray-di-for-laravel demo code.
All versions of ray-di-for-laravel with dependencies
ray/di Version ^2.15.1
ray/compiler Version ^1.10
doctrine/cache Version ^1.10 || ^2.2