1. Go to this page and download the library: Download studiow/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/ */
studiow / autowire example snippets
class Configuration
{
//...
}
interface HasConfiguration
{
public function setConfiguration(Configuration $configuration);
public function getConfiguration():Configuration
}
$container = new League\Container\Container();
$container->share(Configuration::class);
class AClassWithConfiguration implements HasConfiguration{
//...
}
$container->share(AClassWithConfiguration::class, function() use($container){
$obj = new AClassWithConfiguration();
$obj->setConfiguration($container->get(Configuration::class));
return $obj;
});
$container = new League\Container\Container();
$container->share(Configuration::class);
$awContainer = Studiow\Autowire\Container($container);