This package provides a possibility to lazy load dependencies using attribute.
You can install the package via composer:
composer require laravel-tools/lazy-dependencyIf you discover any security related issues, please email [email protected] instead of using the issue tracker.
Trait is required to be used. Recommended way is to create base abstract class for Controller, Services etc. and use that trait in that base class.
new class {
use UseDependency;
#[Dependency]
readonly protected ExampleClass $service;
public function hello(): string
{
return $this->service->hello();
}
};To start developing first you must install the dependencies:
docker run --rm -v $(pwd):/app composer installTo test the package you can run:
docker run --rm -v $(pwd):/app -w /app php:8.3-cli vendor/bin/pest