2017 © Pedro Peláez
 

symfony1-plugin sy-dependency-injection-plugin

symfony 1.x plugin for Symfony Dependency Injection component SF2.

image

symflo/sy-dependency-injection-plugin

symfony 1.x plugin for Symfony Dependency Injection component SF2.

  • Thursday, November 21, 2013
  • by symflo
  • Repository
  • 1 Watchers
  • 2 Stars
  • 20 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

SyDependencyInjectionPlugin

use Symfony DependencyInjection Component SF2 on SF1., (*1)

Requirements

  • PHP 5.3.3+

Installation

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',
        ));
    }
}
?>

Configuration

Two possibilities:, (*5)

Locator files

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
          ...

Extensions

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)

Then in your Action

getContainer();
    $service = $this->getService('your.service');
}

//...
?>

Or for example in a Task

configuration);
    $container = $context->get('dependency_injection_container');
    $service = $container->get('your.service');
}

//...
?>

The Versions

21/11 2013

dev-master

9999999-dev

symfony 1.x plugin for Symfony Dependency Injection component SF2.

  Sources   Download

MIT

The Requires

 

by Avatar symflo

symfony dependency injection