2017 © Pedro Peláez
 

symfony-bundle lazy-services-bundle

Bundle for marking services and arguments as "lazy"

image

matthiasnoback/lazy-services-bundle

Bundle for marking services and arguments as "lazy"

  • Thursday, July 11, 2013
  • by matthiasnoback
  • Repository
  • 2 Watchers
  • 18 Stars
  • 25 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

LazyServicesBundle

By Matthias Noback, (*1)

Build Status, (*2)

Installation

Run:, (*3)

php composer.phar require matthiasnoback/lazy-services-bundle 0.2.*

Then register the bundle in /app/AppKernel.php:, (*4)

<?php

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Matthias\LazyServicesBundle\MatthiasLazyServicesBundle,
        );
    }
}

Usage

Lazy arguments

This bundle allows you to mark services as lazy by adding tags to arguments that refer to them:, (*5)

<service id="some_service" class="...">
    <argument type="service" id="mailer" key="mailer" />
    <tag name="lazy_argument" key="mailer" />
</service>

The argument key can be a string (like in the example above), or a number, indicating the index of the argument (starting with 0):, (*6)

<service id="some_service" class="...">
    <argument type="service" id="event_dispatcher" /><!-- key is 0 -->
    <argument type="service" id="mailer" /><!-- key is 1 -->
    <tag name="lazy_argument" key="1" />
</service>

Both examples will effectively convert the mailer service to a lazy-loading service., (*7)

When the referenced service does not exist, it will be skipped silently., (*8)

Lazy services by configuration

For your convenience, this bundle also allows you to mark services as lazy by adding its service id to a list of lazy services in your application configuration:, (*9)

# in config.yml:

matthias_lazy_services:
    lazy_service_ids:
        - mailer
        - ...

When the referenced service does not exist, it will be skipped silently., (*10)

The Versions

11/07 2013

dev-master

9999999-dev http://github.com/matthiasnoback/LazyServicesBundle

Bundle for marking services and arguments as "lazy"

  Sources   Download

MIT

The Requires

 

The Development Requires

service proxy lazy

11/07 2013

v0.2.0

0.2.0.0 http://github.com/matthiasnoback/LazyServicesBundle

Bundle for marking services and arguments as "lazy"

  Sources   Download

MIT

The Requires

 

The Development Requires

service proxy lazy

09/07 2013

v0.1.0

0.1.0.0 http://github.com/matthiasnoback/LazyServicesBundle

Bundle for marking services and arguments as "lazy"

  Sources   Download

MIT

The Requires

 

The Development Requires

service proxy lazy