1. Go to this page and download the library: Download tyler/envase 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/ */
$c->set('foo', fn(Envase\Container $c) => new Bar);
// or the short hand helper
$c->set('foo', Envase\get(Bar::class))
$bar = $c->get('foo'); // <-- will result in calling the closure
class Foo
{
public function __construct(
public Bar $bar,
public string $dirToSomething
)
}
class Bar
{
}
$c = new Envase\Container([
'dirToSomething' => '/path/to/somewhere'
]);
$foo = $c->get(Foo::class);
class Foo
{
#[Inject]
private Bar $bar; // will auto inject instance of Bar
#[Inject]
private string $foo // Will auto inject key foo, value will be 'bar'
#[Inject("fizz")]
private string $something // Will auto inject key fizz, value will be 'buzz'
}
class Bar
{
}
$c = new Envase\Container([
'foo' => 'bar',
'fizz' => 'buzz'
]);
$foo = $c->get(Foo::class); // will be instance of Foo
$foo = $c->make(Foo::class);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.