1. Go to this page and download the library: Download jasny/autowire 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/ */
jasny / autowire example snippets
class Foo
{
public function __construct(ColorInterface $color)
{
// ...
}
}
use Jasny\Autowire\ReflectionAutowire();
$autowire = new ReflectionAutowire($container);
$foo = $autowire->instantiate(Foo::class);
// OR
$foo = $autowire(Foo::class);
class Foo
{
public function __construct(?ColorInterface $color)
{
// ...
}
}
class Bar
{
/**
* Class constructor
*
* @param string $color "config:bar_color"
* @param ConnectionInterface $connection "db_connections.default"
*/
public function __construct(string $color, ConnectionInterface $connection)
{
// ...
}
}
class Bar
{
/**
* Class constructor
*
* @param string $color A color
* @param ConnectionInterface $connection "db_connections.default"
*/
public function __construct(string $color, ConnectionInterface $connection)
{
// ...
}
}
use Jasny\Autowire\ReflectionAutowire();
$autowire = new ReflectionAutowire($container);
$foo = $autowire->instantiate(Foo::class, 'blue');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.