2017 © Pedro Peláez
 

library default-autowire

Adds autowire to services when needed.

image

symplify/default-autowire

Adds autowire to services when needed.

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 39 Versions
  • 7 % Grown

The README.md

Default Autowire

Build Status Code Coverage Downloads, (*1)

This bundle turns on autowire for you!, (*2)

It turns this:, (*3)

# app/config/config.yml
services:
    PriceCalculator:
        autowire: true

    ProductRepository:
        autowire: true

    UserFactory:
        autowire: true

Into this:, (*4)

# app/config/config.yml
services:
    PriceCalculator: ~
    ProductRepository: ~
    UserFactory: ~

Install

composer require symplify/default-autowire

Add bundle to AppKernel.php:, (*5)

final class AppKernel extends Kernel
{
    public function registerBundles(): array
    {
        $bundles = [
            new Symplify\DefaultAutowire\SymplifyDefaultAutowireBundle(),
            // ...
        ];
    }
}

And that's it!, (*6)

Features

Multiple service of one type? Set preferred one

In case you have multiple connections, entity managers or decorated service, you can set default preferred service (name) for each type (class or interface)., (*7)

To make it easier for you, there are few default values. You can change them or add new ones., (*8)

# app/config/cofing.yml
symplify_default_autowire:
    autowire_types:
        Doctrine\ORM\EntityManager: 'doctrine.orm.default_entity_manager'
        Doctrine\ORM\EntityManagerInterface: 'doctrine.orm.default_entity_manager'
        Doctrine\Portability\Connection: 'database_connection'
        Symfony\Component\EventDispatcher\EventDispatcher: 'event_dispatcher'
        Symfony\Component\EventDispatcher\EventDispatcherInterface: 'event_dispatcher'
        Symfony\Component\Translation\TranslatorInterface: 'translator'

Contributing

Send issue or pull-request to main repository., (*9)

The Versions

13/05 2016

v0.2.1

0.2.1.0

Adds autowire to services when needed.

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony autowire

24/02 2016

v0.2.0

0.2.0.0

Adds autowire to services when needed.

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony autowire

01/02 2016

v0.1.0

0.1.0.0

Adds autowire to services when needed.

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony autowire