2017 © Pedro Peláez
 

library iocconf

ioc container configuration using xml

image

thapp/iocconf

ioc container configuration using xml

  • Tuesday, April 30, 2013
  • by iwyg
  • Repository
  • 1 Watchers
  • 1 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Populate and configure Laravel's IoC container with xml

Build Status, (*1)

Synopsis

IoCConf provides a convenient way to handle dependecy injection using xml. E.g. it is possible to setup your controllers with either contructor or setter injection., (*2)

Installation

IocConf requires XmlConf to work., (*3)

Add thapp/iocconf ans thapp/xmlconf as a requirement to composer.json:, (*4)

{
    "require": {
        "thapp/iocconf": "1.0.*",
        "thapp/xmlconf": "1.0.*"
    }
}

Then run composer update or composer install, (*5)

Next step is to tell laravel to load the serviceprovider. In app/config/app.php add, (*6)

  // ...
  'Thapp\IocConf\IocConfServiceProvider' 
  // ...

to the providers array., (*7)

Make sure XmlConf is installed properly, then tell XmlConf where to find the ioc configuration (app/config/packages/thapp/xmlconf/config.php), (*8)

return array(

    /*
    |--------------------------------------------------------------------------
    | Basedir relative to the install directory
    |--------------------------------------------------------------------------
     */
    'basedir' => array(
        'ioc'      => 'vendor/thapp/iocconf/src/Thapp/IocConf'
    ),

    /*
    |--------------------------------------------------------------------------
    | Reader dictionary
    |--------------------------------------------------------------------------
     */
    'namespaces' => array(
        'ioc'      => 'Thapp\\IocConf'
    ),
);


Example

Given you want to inject Laravel's view Object into a controller, the xml configuration would look something like this:, (*9)


view = $view; } } ``` The config xml would look like this ```xml ``` ## Usage #### xml Note: An entity node can have an id attribute but must have a class and a scope attribute, An agument node must either have an id or class attribute. Possible entity scopes: ``` - prototype // see Container::bind(); - singleton // see Container::singleton(); - shared // see Container::share(); ``` ```xml <container xmlns="http://getsymphony.com/schema/ioc"> <entities> <entity id="acme.frontcontroller" class="FrontController" scope="prototype"/> <entity id="acme.admincontroller" class="AdminController" scope="prototype"> <call method="setView"> <argument id="view"/> </call> </entity> <entity class="ControllerRepository" scope="singleton"> <argument id="acme.frontcontroller"/> <argument id="acme.admincontroller"/> </entity> </entities> </container>

php

$repo = App::make('ControllerRepository');

$repo2 = App::make('ControllerRepository');

$repo === $repo2 // true

The Versions

30/04 2013

dev-master

9999999-dev

ioc container configuration using xml

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar iwyg

30/04 2013

v1.0.1

1.0.1.0

ioc container configuration using xml

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar iwyg

29/04 2013

v1.0.0

1.0.0.0

ioc container configuration using xml

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar iwyg