yiisoft/definitions
Lightweight definitions library for Yii and PHP DI containers. Provides a consistent way to describe services, factories, references, and parameters for building dependency graphs, resolving callables, and configuring containers with minimal overhead.
yiisoft/di (dependency injection) or yiisoft/arrays, reducing friction in monolithic or hybrid Yii/Laravel stacks.yiisoft/definitions introduces a declarative syntax (e.g., YAML/array-based definitions) that could complement Laravel’s imperative approach (e.g., app()->bind()), especially for:
Illuminate\Container\Container).AppServiceProvider and bind()/singleton() methods may overlap with the package’s goals. A hybrid approach (e.g., using definitions for externalized configs + Laravel bindings for core services) is recommended.boot() method or a custom provider.config/services.php.config(), env()) requires custom glue code.bind()/singleton()? (e.g., externalized configs, dynamic service composition).DefinitionTestCase)?bind()/singleton() for externalized or dynamic services.config/services/definitions.yaml) instead of hardcoding in PHP.yiisoft/di).AppServiceProvider with definitions loaded from a YAML file.# config/services/definitions.yaml
services:
logger:
class: App\Services\CustomLogger
params:
logLevel: "debug"
filePath: "/var/log/custom.log"
// In a service provider
$definitions = DefinitionLoader::load(__DIR__.'/../../config/services/definitions.yaml');
foreach ($definitions->get('services') as $name => $def) {
$this->app->bind($name, fn() => $def->getObject($this->app));
}
yiisoft/di (for object instantiation) or similar DI containers.yiisoft/arrays).config() system can load these formats natively, reducing parsing overhead.config/services/definitions/ directory for YAML/array files.How can I help you explore Laravel packages today?