useAnnotations() public method

Disabled by default.
public useAnnotations ( boolean $bool ) : ContainerBuilder
$bool boolean
return ContainerBuilder
Example #1
1
 /**
  * @param $env
  * @return Container
  */
 public function getContainer($env)
 {
     $container = null;
     $builder = new ContainerBuilder(Container::class);
     //        $builder = new ContainerBuilder();
     foreach (glob(APP_HOME . '/conf/conf.d/*.conf.php') as $filename) {
         $builder->addDefinitions($filename);
     }
     $definitionsEnumFile = APP_HOME . '/conf/config.' . $env . '.php';
     if (file_exists($definitionsEnumFile)) {
         $builder->addDefinitions($definitionsEnumFile);
     }
     $builder->useAnnotations(false);
     $builder->useAutowiring(true);
     switch ($env) {
         case EnvironmentEnum::DEV:
             $builder->setDefinitionCache(new ArrayCache());
             break;
         case EnvironmentEnum::PROD:
         default:
             $cache = $this->getCache();
             $builder->setDefinitionCache($cache);
             $builder->writeProxiesToFile(true, APP_HOME . '/var/cache/proxies');
             break;
     }
     $container = $builder->build();
     return $container;
 }
Example #2
0
 /**
  * @param $env
  * @return \DI\Container
  */
 public function getContainer($env)
 {
     $builder = new ContainerBuilder();
     foreach (glob(APP_HOME . '/conf/conf.d/*.conf.php') as $filename) {
         $builder->addDefinitions($filename);
     }
     $builder->addDefinitions(APP_HOME . '/conf/config.' . $env . '.php');
     switch ($env) {
         case EnvironmentEnum::DEV:
             $builder->setDefinitionCache(new ArrayCache());
             break;
         case EnvironmentEnum::PROD:
             $redis = new Redis();
             $redis->pconnect('localhost');
             $redis->setOption(Redis::OPT_PREFIX, 'homeservice:cache:di:');
             $cache = new RedisCache();
             $cache->setRedis($redis);
             $builder->setDefinitionCache($cache);
             $builder->writeProxiesToFile(true, APP_HOME . '/var/cache/proxies');
             break;
     }
     $builder->useAnnotations(true);
     $container = $builder->build();
     return $container;
 }
 /**
  * @link http://php-di.org/doc/container-configuration.html
  * @throws \Exception
  * @return Container
  */
 public function create()
 {
     $builder = new ContainerBuilder();
     $builder->useAnnotations(false);
     $builder->setDefinitionCache(new ArrayCache());
     // INI config
     $builder->addDefinitions(new IniConfigDefinitionSource($this->settings));
     // Global config
     $builder->addDefinitions(PIWIK_USER_PATH . '/config/global.php');
     // Plugin configs
     $this->addPluginConfigs($builder);
     // Development config
     if ($this->isDevelopmentModeEnabled()) {
         $builder->addDefinitions(PIWIK_USER_PATH . '/config/environment/dev.php');
     }
     // User config
     if (file_exists(PIWIK_USER_PATH . '/config/config.php')) {
         $builder->addDefinitions(PIWIK_USER_PATH . '/config/config.php');
     }
     // Environment config
     foreach ($this->environments as $environment) {
         $this->addEnvironmentConfig($builder, $environment);
     }
     if (!empty($this->definitions)) {
         foreach ($this->definitions as $definitionArray) {
             $builder->addDefinitions($definitionArray);
         }
     }
     $container = $builder->build();
     $container->set('Piwik\\Application\\Kernel\\PluginList', $this->pluginList);
     $container->set('Piwik\\Application\\Kernel\\GlobalSettingsProvider', $this->settings);
     return $container;
 }
Example #4
0
 /**
  * @link http://php-di.org/doc/container-configuration.html
  * @throws \Exception
  * @return Container
  */
 public function create()
 {
     $builder = new ContainerBuilder();
     $builder->useAnnotations(false);
     $builder->setDefinitionCache(new ArrayCache());
     // INI config
     $builder->addDefinitions(new IniConfigDefinitionSource(Config::getInstance()));
     // Global config
     $builder->addDefinitions(PIWIK_USER_PATH . '/config/global.php');
     // Plugin configs
     $this->addPluginConfigs($builder);
     // Development config
     if (Development::isEnabled()) {
         $builder->addDefinitions(PIWIK_USER_PATH . '/config/environment/dev.php');
     }
     // User config
     if (file_exists(PIWIK_USER_PATH . '/config/config.php')) {
         $builder->addDefinitions(PIWIK_USER_PATH . '/config/config.php');
     }
     // Environment config
     $this->addEnvironmentConfig($builder);
     if (!empty($this->definitions)) {
         $builder->addDefinitions($this->definitions);
     }
     return $builder->build();
 }
Example #5
0
 /**
  * Container compilation.
  *
  * @param mixed $config Configuration file/array.
  *
  * @link http://php-di.org/doc/php-definitions.html
  *
  * @return ContainerInterface
  */
 private function buildContainer($config)
 {
     $builder = new DI\ContainerBuilder();
     $builder->useAnnotations(true);
     $builder->addDefinitions($config);
     return $builder->build();
 }
 /**
  * @inheritDoc
  */
 protected function setUp()
 {
     parent::setUp();
     $builder = new ContainerBuilder();
     $builder->useAutowiring(true);
     $builder->useAnnotations(true);
     $this->container = $builder->build();
 }
Example #7
0
 /**
  * Initial setup of DI\ContainerBuilder.
  *
  * @param bool $annotation annotation usage.
  *
  * @return DI\ContainerBuilder
  */
 protected static function initialSetupContainerBuilder($annotation)
 {
     $builder = new DI\ContainerBuilder();
     $builder->useAnnotations($annotation);
     $builder->addDefinitions(['request' => ServerRequestFactory::fromGlobals(), 'response' => DI\object(Response::class), 'http_flow_event' => DI\object(ZendHttpFlowEvent::class)->constructor('bootstrap', DI\get('request'), DI\get('response')), 'event_manager' => DI\object(ZendEvmProxy::class), 'dispatcher' => DI\factory(function ($container) {
         return new Dispatcher($container->get('router'), $container);
     })]);
     return $builder;
 }
Example #8
0
 /**
  * @param string $token
  * @param string $uri
  */
 public function __construct($token, $uri = 'http://www.ifsistem.com/api/v1')
 {
     $builder = new ContainerBuilder(Container::class);
     $builder->useAnnotations(true);
     $builder->addDefinitions(['sayfa' => \DI\get(SayfaService::class), 'menu' => \DI\get(MenuService::class), 'manset' => \DI\get(MansetService::class), 'haber' => \DI\get(HaberService::class), 'galeri' => \DI\get(GaleriService::class), 'iletisimMesaj' => \DI\get(IletisimMesajService::class), 'site' => \DI\get(SiteService::class), 'sehir' => \DI\get(SehirService::class), 'ilce' => \DI\get(IlceService::class), 'semt' => \DI\get(SemtService::class), 'emlak' => \DI\get(EmlakService::class), 'urun' => \DI\get(UrunService::class), 'kullanici' => \DI\get(KullaniciService::class), 'resim' => \DI\get(ResimService::class), 'reklam' => \DI\get(ReklamService::class), 'siparis' => \DI\get(SiparisService::class), 'sanat' => \DI\get(SanatService::class), 'grup' => \DI\get(GrupService::class), 'reference' => \DI\get(ReferenceService::class), 'api' => function () use($token, $uri) {
         return new ApiService($token, $uri);
     }, ApiService::class => \DI\get('api')]);
     // test
     $this->container = $builder->build();
 }
Example #9
0
 public function setUp()
 {
     $this->router = FastRoute\simpleDispatcher(function (FastRoute\RouteCollector $router) {
         $router->addRoute('GET', '/', ['TestApp\\Controller\\Index', 'diTest']);
     });
     $builder = new ContainerBuilder();
     $builder->useAnnotations(true);
     $dic = $builder->build();
     $this->container = $dic;
 }
Example #10
0
 /**
  * Настраиваем контейнер.
  */
 protected function setContainer()
 {
     $builder = new ContainerBuilder();
     $builder->useAnnotations(false);
     if ($this->options['dependencies']) {
         $builder->addDefinitions($this->options['dependencies']);
     }
     $builder->writeProxiesToFile((bool) $this->options['containerProxy'], is_string($this->options['containerProxy']) ? $this->options['containerProxy'] : sys_get_temp_dir());
     $this->container = $builder->build();
 }
Example #11
0
 protected function setUp()
 {
     $config = ['app' => "this is my app", "test" => "prova", "version" => "0.0.1", 'routes' => [['name' => 'hello', 'route' => "--name=", 'short_description' => "Good morning!! This is a beautiful day", "handler" => ['App\\Command\\Hello', 'run']]], "service_manager" => ["invokables" => [], "factories" => []]];
     $builder = new ContainerBuilder();
     $builder->useAnnotations(true);
     $builder->addDefinitions($config);
     $container = $builder->build();
     $configServiceManager = new Config($config['service_manager']);
     $container->set("service_manager", new ServiceManager($configServiceManager));
     $this->application = new Application($config['app'], $config['version'], $config['routes'], Console::getInstance(), new Dispatcher($container));
 }
Example #12
0
 /**
  * Container compilation.
  *
  * @param mixed $config Configuration file/array.
  *
  * @link http://php-di.org/doc/php-definitions.html
  *
  * @return ContainerInterface
  */
 public static function buildContainer($config = [])
 {
     $builder = new DI\ContainerBuilder();
     $builder->useAnnotations(true);
     $builder->addDefinitions(['request' => \Zend\Diactoros\ServerRequestFactory::fromGlobals(), 'response' => DI\object('Zend\\Diactoros\\Response'), 'http_flow_event' => DI\object('Penny\\Event\\HttpFlowEvent')->constructor('bootstrap', DI\get('request'), DI\get('response')), 'event_manager' => DI\object('Zend\\EventManager\\EventManager'), 'dispatcher' => DI\factory(function ($container) {
         return new \Penny\Dispatcher($container->get('router'), $container);
     })]);
     $builder->addDefinitions($config);
     $container = $builder->build();
     $container->set('di', $container);
     return $container;
 }
Example #13
0
 public function testCorrectInjectionWithExternalContainer()
 {
     $builder = new ContainerBuilder();
     $builder->addDefinitions(Loader::load());
     $builder->useAnnotations(true);
     $app = new App($this->router, $builder->build());
     $request = (new Request())->withUri(new Uri('/load'))->withMethod('GET');
     $response = new Response();
     $response = $app->run($request, $response);
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals('eureka', $response->getBody()->__toString());
 }
Example #14
0
 /**
  * @throws \Exception
  */
 protected function __construct()
 {
     $builder = new ContainerBuilder();
     $builder->useAutowiring(false);
     $builder->useAnnotations(false);
     $configFile = sprintf(dirname(dirname(dirname(dirname(dirname(__DIR__))))) . '/config/' . self::CONFIG_FILE_PATTERN, self::$env);
     if (!file_exists($configFile)) {
         throw new \Exception(sprintf("The config file expected '%s' doesn't exist", $configFile));
     }
     $builder->addDefinitions($configFile);
     $container = $builder->build();
     self::$instance = $container;
 }
 /**
  * Configure container builder.
  *
  * @param \DI\ContainerBuilder $containerBuilder
  * @param array                $settings
  *
  * @return \DI\ContainerBuilder
  */
 private static function configureContainerBuilder(DIContainerBuilder $containerBuilder, array $settings)
 {
     if (array_key_exists('use_autowiring', $settings)) {
         $containerBuilder->useAutowiring((bool) $settings['use_autowiring']);
     }
     if (array_key_exists('use_annotations', $settings)) {
         $containerBuilder->useAnnotations((bool) $settings['use_annotations']);
     }
     if (array_key_exists('ignore_phpdoc_errors', $settings)) {
         $containerBuilder->ignorePhpDocErrors((bool) $settings['ignore_phpdoc_errors']);
     }
     return $containerBuilder;
 }
 public function register(Application $app)
 {
     $app['di.definitions'] = array();
     $app['di.options'] = array();
     $app['di.default_options'] = array('cache' => null, 'container_class' => 'DI\\Container', 'useAnnotations' => true, 'useAutowiring' => true, 'writeProxiesToFile' => false, 'proxyDirectory' => null, 'silexAliases' => true, 'injectOnControllers' => true);
     $app['di'] = $app->share(function () use($app) {
         $acclimator = new ContainerAcclimator();
         $container = new CompositeContainer();
         $builder = $app['di.builder'];
         $builder->wrapContainer($container);
         $phpdi = $builder->build();
         $phpdi->set('Silex\\Application', $app);
         $container->addContainer($acclimator->acclimate($phpdi));
         $container->addContainer($acclimator->acclimate($app));
         return $container;
     });
     $app['di.builder'] = $app->share(function () use($app) {
         $options = $app['di.options_merged'];
         $builder = new ContainerBuilder($options['container_class']);
         $builder->useAnnotations((bool) $options['useAnnotations']);
         $builder->useAutowiring((bool) $options['useAutowiring']);
         $builder->writeProxiesToFile($options['writeProxiesToFile'], $options['proxyDirectory']);
         if ($options['cache']) {
             $builder->setDefinitionCache($options['cache']);
         }
         $definitions = (array) $app['di.definitions'];
         if ($options['silexAliases']) {
             $definitions[] = __DIR__ . '/config.php';
         }
         foreach ($definitions as $file) {
             $builder->addDefinitions($file);
         }
         return $builder;
     });
     $app['di.raw'] = $app->share(function () use($app) {
         return $app['di']->get($app['di.options_merged']['container_class']);
     });
     $app['di.options_merged'] = $app->share(function () use($app) {
         return array_merge($app['di.default_options'], $app['di.options']);
     });
     $app['resolver'] = $app->share($app->extend('resolver', function ($resolver, $app) {
         if ($app['di.options_merged']['injectOnControllers']) {
             return new PhpDiControllerResolver($app['di.raw'], $resolver);
         }
         return $resolver;
     }));
 }
Example #17
0
 public function setUp()
 {
     $loader = (include __DIR__ . '/../vendor/autoload.php');
     AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
     $container = new CompositeContainer();
     $builder = new ContainerBuilder();
     $builder->useAnnotations(true);
     $builder->wrapContainer($container);
     $diContainer = $builder->build();
     $container->addContainer($diContainer);
     $reader = new AnnotationReader();
     $routeLoader = new RouteAnnotationClassLoader($reader);
     $loader = new AnnotationDirectoryLoader(new FileLocator([__DIR__ . '/app']), $routeLoader);
     $routes = $loader->load(__DIR__ . '/app');
     $context = new RequestContext();
     $matcher = new UrlMatcher($routes, $context);
     $hookReader = new HookReader($reader);
     $executor = new AnnotExecutor($container, $hookReader);
     $this->app = new App($matcher, $executor);
 }
 /**
  * Boots the dependency injection container.
  *
  * @param \Domynation\Config\ConfigInterface $config
  * @param \Domynation\Session\SessionInterface $session
  *
  * @return \DI\Container
  */
 private function bootContainer(ConfigInterface $config, SessionInterface $session)
 {
     $builder = new ContainerBuilder();
     $builder->useAnnotations(false);
     // Cache the definitions in production
     if (IS_PRODUCTION) {
         $builder->setDefinitionCache(new ApcuCache());
     }
     // Load all global services
     $builder->addDefinitions(array_merge(require_once __DIR__ . '/Files/container.php', [ConfigInterface::class => $config, SessionInterface::class => $session]));
     // First pass: Instanciate each providers and load their container definitions
     $providers = array_reduce($config->get('providers'), function ($accumulator, $name) use($builder) {
         if (!class_exists($name)) {
             return $accumulator;
         }
         // Instanciate the provider
         $reflection = new \ReflectionClass($name);
         $provider = $reflection->newInstanceArgs();
         // Load the provider's container definitions
         $builder->addDefinitions($provider->registerContainerDefinitions());
         $accumulator[] = $provider;
         return $accumulator;
     });
     // Build the container
     $container = $builder->build();
     // Second pass: Boot each service
     foreach ($providers as $provider) {
         // Start the provider
         $provider->start($container->get(Router::class), $container->get(ViewFactoryInterface::class), $container->get(EventDispatcherInterface::class));
         // Use reflection to get a closure copy of the `boot` method
         $reflection = new \ReflectionClass(get_class($provider));
         $closure = $reflection->getMethod('boot')->getClosure($provider);
         // Let the container inject the dependency needed by the closure
         $container->call($closure);
     }
     return $container;
 }
Example #19
0
 /**
  * Create service
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @return Container
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     if ($this->container !== null) {
         return $this->container;
     }
     $builder = new ContainerBuilder();
     $config = $this->getConfig($serviceLocator);
     $configFile = $this->getDefinitionsFilePath($config);
     $builder->addDefinitions($configFile);
     $useAnnotations = $this->shouldUseAnnotations($config);
     $builder->useAnnotations($useAnnotations);
     $acclimator = new ContainerAcclimator();
     $zfContainer = $acclimator->acclimate($serviceLocator);
     $builder->wrapContainer($zfContainer);
     /**
      * @var $cache Cache
      */
     $cache = $this->getCache($serviceLocator, $config);
     if ($cache) {
         $builder->setDefinitionCache($cache);
     }
     $this->container = $builder->build();
     return $this->container;
 }
 /**
  * {@inheritdoc}
  */
 public function init()
 {
     parent::init();
     $environment = Config::getSystemConfig()->get("general")->get("environment");
     // Set up dependency injection container
     $builder = new ContainerBuilder();
     $builder->useAnnotations(true);
     // Configure the container
     $builder->addDefinitions(PIMCORE_WEBSITE_PATH . "/config/container.php");
     if ($environment !== "local") {
         // Use whatever cache Pimcore has configured (if it has one configured) to cache object
         // definitions in the container
         $builder->setDefinitionCache(new PimcoreCache());
     } else {
         // For development, or debugging we don't want to cache the container
         $builder->setDefinitionCache(new ArrayCache());
     }
     $environmentConfigFile = DefinitionFileLocator::getPath($environment);
     $parametersFile = ParametersFileLocator::getPath();
     if (file_exists($environmentConfigFile)) {
         $builder->addDefinitions($environmentConfigFile);
     }
     if (file_exists($parametersFile)) {
         $builder->addDefinitions($parametersFile);
     }
     $container = $builder->build();
     /** @var \Zend_Controller_Dispatcher_Interface $currentDispatcher */
     $currentDispatcher = \Zend_Controller_Front::getInstance()->getDispatcher();
     $dispatcher = new Dispatcher();
     $dispatcher->setContainer($container);
     $dispatcher->setControllerDirectory($currentDispatcher->getControllerDirectory());
     $dispatcher->setDefaultModule($currentDispatcher->getDefaultModule());
     $dispatcher->setDefaultAction($currentDispatcher->getDefaultAction());
     $dispatcher->setDefaultControllerName($currentDispatcher->getDefaultControllerName());
     \Zend_Controller_Front::getInstance()->setDispatcher($dispatcher);
 }
 public function initContainer()
 {
     $config = $this->getConfig();
     $builder = new ContainerBuilder();
     $builder->useAnnotations(true);
     // add definitions and create definition cache if definitions enabled
     if ($config->get('useDefinitionFiles', true)) {
         $this->addDefinitions($builder);
         $builder->setDefinitionCache($this->createDefinitionCache($config->get('cache')));
     }
     // use proxy cache if enabled
     if ($writeProxiesToFile = $config->get('cacheProxies', true)) {
         $proxyDir = new FileLocator(self::PROXY_DIR);
         $builder->writeProxiesToFile($writeProxiesToFile, $proxyDir->getPath());
     }
     // dispatch event to enable other plugins to extend the container
     \Pimcore::getEventManager()->trigger(self::CONTAINER_INIT_EVENT, $builder);
     $this->container = $builder->build();
     // create action helper
     $this->initActionHelper();
     // add container to registry
     \Zend_Registry::set(self::CONTAINER_REGISTRY_KEY, $this->container);
     // dispatch event to inform others that the container is ready
     \Pimcore::getEventManager()->trigger(self::CONTAINER_INITIALIZED_EVENT, $this->container);
 }
Example #22
0
 /**
  * Run the app
  */
 public function run()
 {
     $containerBuilder = new ContainerBuilder();
     $containerBuilder->addDefinitions(__DIR__ . '/../app/config.php');
     $containerBuilder->addDefinitions($this->diConfigFile);
     $containerBuilder->addDefinitions(array_merge(['workshopTitle' => $this->workshopTitle, 'exercises' => $this->exercises, 'workshopLogo' => $this->logo, 'bgColour' => $this->bgColour, 'fgColour' => $this->fgColour]));
     $containerBuilder->useAutowiring(false);
     $containerBuilder->useAnnotations(false);
     $container = $containerBuilder->build();
     foreach ($this->exercises as $exercise) {
         if (false === $container->has($exercise)) {
             throw new \RuntimeException(sprintf('No DI config found for exercise: "%s". Register a factory.', $exercise));
         }
     }
     $checkRepository = $container->get(CheckRepository::class);
     array_walk($this->checks, function (CheckInterface $check) use($checkRepository) {
         $checkRepository->registerCheck($check);
     });
     try {
         $exitCode = $container->get(CommandRouter::class)->route();
     } catch (MissingArgumentException $e) {
         $container->get(OutputInterface::class)->printError(sprintf('Argument%s: "%s" %s missing!', count($e->getMissingArguments()) > 1 ? 's' : '', implode('", "', $e->getMissingArguments()), count($e->getMissingArguments()) > 1 ? 'are' : 'is'));
         return 1;
     }
     return $exitCode;
 }
Example #23
0
 /**
  * Makes sure the dependency injection is working with annotations
  */
 public function testContainerOnInjectWorks()
 {
     $builder = new ContainerBuilder();
     $builder->useAutowiring(false);
     $builder->useAnnotations(true);
     $container = $builder->build();
     $router = new Router($container);
     $result = $router->map(new Route('/', DummyController::class, 'index'), new Route('/di/injected', DummyController::class, 'injected'))->run('/di/injected');
     $this->assertEquals('stdClass', $result);
 }
Example #24
0
<?php

use DI\ContainerBuilder;
return call_user_func(function () {
    $builder = new ContainerBuilder();
    $builder->useAnnotations(false);
    $builder->useAutowiring(false);
    $builder->addDefinitions(['cache_path' => '/tmp/cache', CacheProvider::class => \DI\object(FileCache::class)->constructorParameter('path', \DI\get('cache_path')), UserRepository::class => \DI\object()->constructorParameter('cache', \DI\get(CacheProvider::class))]);
    return $builder->build();
});
Example #25
0
 /**
  * Efetua algumas configurações avançadas do sistema.
  */
 private function config()
 {
     Config::getInstance()->set('ANNA_PATH', __DIR__ . DS);
     if (is_callable('uncaughtExceptionHandler')) {
         set_exception_handler('uncaughtExceptionHandler');
     }
     // Implementando o Dependence Injection automatizado
     $di_builder = new ContainerBuilder();
     $di_builder->useAnnotations(true);
     $this->di = $di_builder->build();
 }
Example #26
0
use Stash\Pool as Cache;
use Stash\Driver\Ephemeral as CacheDriver;
use Stash\Interfaces\PoolInterface as ICache;
use Stash\Interfaces\DriverInterface as ICacheDriver;
// Create a new silly cli app
// see: http://mnapoli.fr/silly/
$app = new Silly\Application();
// We will use php-di as our IoC container
// see: http://php-di.org/
$builder = new ContainerBuilder();
// We need to somehow do the caching at build time.
// And then only read from the cache when we detect
// that we are running inside a phar.
//$builder->writeProxiesToFile();
//$builder->setDefinitionCache();
$builder->useAnnotations(true);
$builder->addDefinitions(['vendor.dir' => 'ppm_packages', 'packagist.url' => 'https://packagist.org/packages/', 'semver.minimum-stability' => 'stable', IHttp::class => object(Http::class), IFilesystem::class => object(Filesystem::class), IFileAdapter::class => function () {
    return new Local(getcwd());
}, ICache::class => object(Cache::class), ICacheDriver::class => object(CacheDriver::class), Contracts\IConflictDiscoverer::class => object(Services\ConflictDiscoverer::class), Contracts\IPackageCleaner::class => object(Services\PackageCleaner::class), Contracts\IZipExtractor::class => object(Services\ZipExtractor::class), Contracts\IPackageReNamer::class => object(Services\PackageReNamer::class), Contracts\IComposerFileReader::class => object(Services\ComposerFileReader::class), Contracts\IPackageDownloader::class => object(Services\PackageDownloader::class), Contracts\ISemVerSolver::class => object(Services\SemVerSolver::class), Contracts\ITypeExtractor::class => object(Services\TypeExtractor::class), Contracts\IReNameVisitor::class => object(Services\ReNameVisitor::class), Contracts\IProxyGenerator::class => object(Services\ProxyGenerator::class), Contracts\IAutoLoaderGenerator::class => object(Services\AutoLoaderGenerator::class), IParser::class => function () {
    return (new ParserFactory())->create(ParserFactory::PREFER_PHP7);
}, ITraverser::class => object(NodeTraverser::class)->method('addVisitor', get(NameResolver::class))]);
// Make silly use php-di
$app->useContainer($builder->build(), true, true);
// Define our commands
$app->command('init', 'Brads\\Ppm\\Commands\\Initalise');
$app->command('install', 'Brads\\Ppm\\Commands\\Install')->descriptions('Installs the project dependencies from the composer.lock ' . 'file if present, or falls back on the composer.json.');
$app->command('update', 'Brads\\Ppm\\Commands\\Update');
$app->command('remove', 'Brads\\Ppm\\Commands\\Remove');
$app->command('require', 'Brads\\Ppm\\Commands\\Require');
$app->command('global', 'Brads\\Ppm\\Commands\\Global');
$app->command('create-project', 'Brads\\Ppm\\Commands\\CreateProject');
Example #27
0
 /**
  * @return \DI\Container
  */
 private function getContainer()
 {
     $containerBuilder = new ContainerBuilder();
     $containerBuilder->addDefinitions(array_merge_recursive(require $this->frameworkConfigLocation, require $this->diConfigFile));
     $containerBuilder->addDefinitions(['workshopTitle' => $this->workshopTitle, 'exercises' => $this->exercises, 'workshopLogo' => $this->logo, 'bgColour' => $this->bgColour, 'fgColour' => $this->fgColour]);
     $containerBuilder->useAutowiring(false);
     $containerBuilder->useAnnotations(false);
     return $containerBuilder->build();
 }