dev-master
9999999-devsymfony 1.x plugin for Symfony Dependency Injection component SF2.
MIT
The Requires
by symflo
symfony dependency injection
symfony 1.x plugin for Symfony Dependency Injection component SF2.
use Symfony DependencyInjection Component SF2 on SF1., (*1)
Add autoload Composer on your symfony project.
In the config/ProjectConfiguration.class.php
add:, (*2)
<?php require_once __DIR__.'/../vendor/autoload.php'; ?>
Add Symfony DependencyInjection Component in your composer.json
, (*3)
"require": { ... "symflo/sy-dependency-injection-plugin": "dev-master" ... },
Activate the plugin in the config/ProjectConfiguration.class.php
., (*4)
enablePlugins(array( /* ... */ 'syDependencyInjectionPlugin', )); } } ?>
Two possibilities:, (*5)
Simple and fast way (not recommanded for big project)
In app.yml
:, (*6)
all: syDependencyInjectionPlugin: enabledDebug: false #true by default - if false, it allows to avoid regenerate container in sf_debug environment locators: defaultFileLocators: dir: %SF_ROOT_DIR%/config/services files: - services.php - services.xml - services.yml ... otherFileLocators: dir: %SF_PLUGIN_DIR%/YourPlugin/config/otherservices files: - services.php ...
all: syDependencyInjectionPlugin: extensions: - MyDefaultExtension - MyOtherExtension compilerPass: custom: class: CustomCompilerPass #passConfig: not required #TYPE_BEFORE_OPTIMIZATION, TYPE_OPTIMIZE, TYPE_BEFORE_REMOVING, TYPE_REMOVE, TYPE_AFTER_REMOVING
Example extension and compilerPass:
Extension in lib\dependencyInjection
., (*7)
load('services.xml'); } public function getXsdValidationBasePath() { return false; } public function getNamespace() { return false; } public function getAlias() { return 'default'; } } ?>
CompilerPass in lib\dependencyInjection\compilerPass
:, (*8)
More informations: Documentation on Component Symfony DependencyInjection, (*9)
Naturaly you can use 2 ways in same time., (*10)
getContainer(); $service = $this->getService('your.service'); } //... ?>
configuration); $container = $context->get('dependency_injection_container'); $service = $container->get('your.service'); } //... ?>
symfony 1.x plugin for Symfony Dependency Injection component SF2.
MIT
symfony dependency injection