, (*1)

, (*2)
Installation | Установка
composer require rudra/container
, (*3)
Using | Использование
use Rudra\Container\Rudra;
Rudra::run();
using Facade | используя фасад:, (*4)
use Rudra\Container\Facades\Rudra;
Setting | Настройка:
Bind an interface to an implementation or pre-arranged factory
Связать интерфейс с реализацией или заранее подготовленной фабрикой:, (*5)
Rudra::run()->binding([
SomeInterface::class => SomeClass::class
...
SomeInterface::class => SomeFactory::class
...
SomeInterface::class => 'service-name'
...
SomeInterface::class => function (){
return new SomeClass();
}
...
SomeInterface::class => function (){
return (new SomeFactory)->create();
}
]);
using Facade | используя фасад:, (*6)
Rudra::binding([
SomeInterface::class => SomeClass::class
...
SomeInterface::class => SomeFactory::class
...
SomeInterface::class => 'service-name'
...
SomeInterface::class => function (){
return new SomeClass();
}
...
SomeInterface::class => function (){
return (new SomeFactory)->create();
}
]);
Installs services into a waiting container to be initialized when called:
Устанавливает сервисы в контейнер ожидающих, для инициализации при вызове:, (*7)
Rudra::run()->waiting([
'service-name' => [SomeClass::class, ['param-1', 'param-2']]
...
'service-name' => SomeFactory::class
...
'service-name' => function (){
return new SomeClass();
}
...
'service-name' => function (){
return (new SomeFactory)->create();
}
}
])
using Facade | используя фасад:, (*8)
Rudra::waiting([
'service-name' => [SomeClass::class, ['param-1', 'param-2']]
...
'service-name' => SomeFactory::class
...
'service-name' => function (){
return new SomeClass();
}
...
'service-name' => function (){
return (new SomeFactory)->create();
}
}
])
Add a bind to previously established ones:
Добавляем привязку к ранее установленным:, (*9)
Rudra::run()->binding()->set([SomeInterface::class => SomeClass::class])
using Facade | используя фасад:, (*10)
Rudra::binding()->set([SomeClass::class, ['param-1', 'param-2']);
Add the service to the previously installed ones:
Добавляем сервис к ранее установленным:, (*11)
Rudra::run()->waiting()->set([
'service-name' => [SomeClass::class, ['param-1', 'param-2']]
...
'service-name' => SomeFactory::class
])
using Facade | используя фасад:, (*12)
Rudra::waiting()->set([
'service-name' => [SomeClass::class, ['param-1', 'param-2']]
...
'service-name' => SomeFactory::class
])
Call the created service:
Вызываем созданный сервис:, (*13)
Rudra::run()->get('service-name')
using Facade | используя фасад:, (*14)
Rudra::get('service-name')
If the service does not have parameters, or the parameters are in the binding, then the service will be created automatically when calling
Если сервис не имеет параметров, либо параметры имеются в привязке, то сервис будет создан автоматически при вызове, (*15)
Rudra::run()->get(Service::class)
using Facade | используя фасад:, (*16)
Rudra::get(Service::class)