1. Go to this page and download the library: Download rudra/container library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rudra / container example snippets
use Rudra\Container\Rudra;
Rudra::run();
use Rudra\Container\Facades\Rudra;
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();
}
]);
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();
}
]);
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();
}
}
])
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();
}
}
])