Symplify packages deprecations brought by Symfony 3.3

Symfony 3.3 brings new Dependency Injection features, that were supplemented by few of Symplify packages in Symfony 3.2 and bellow. There is no need - as Honza Mikes said - to bring the wood to the forest. So they were deprecated.

I will show why and what packages were deprecated and how to upgrade your app to use Symfony 3.3 instead.

I will provide you some insights behind deprecations first. It was not an instant decision based on few Symfony blog posts, but a long process of maturing inspired by community, feedback and intuition.

If you only want to see before/after changes in you application, you can skip right to the code.

Bringing The Wood to the Open Source Forest

One of motivations to create and build open-source project is competition. You want to create better software than there already is, to push the society further in the development. If my project is the best, there is much less motivation to develop it.

That's why it's the best to have 2 elements of similar level so they push each other forward, like: Google & Facebook, USA & Russia, Symfony & Laravel or PHP & Javascript (in a way).

Swallowing My Open-Source Ego

When Symfony 3.3 introduced new Dependency Injection features, I realized they have 90% similar to feature I created my packages for.

Internal dialog of my Ego and inner Zen master started:

So I asked people on Slack and Github what they think about it. Almost everybody (my inner Zen master included) agreed to drop them and let Symfony handle that.

I must say, it was much easier to decide after getting such feedback. Thank you Filip Prochazka, Tomas Fejfar, Stof, theofidry, Jachym Tousek, Jan Mikes and Javier Eguilez for your help with this.

Letting Package Go

I realized I could let packages go and I made these PRs:

That eventually lead to:

Don't worry:

Let's look on each package now:

DefaultAutowire

This package turned on autowiring by default for most of services.

Before

All services were autowired.

After

Use _defaults section:

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

All services in this config will be autowired now. You can use it in any .yml file.

ServiceDefinitionDecorator

This package helped with service tagging and method calls by type.

Before

# app/config/config.yml
decorator:
    Symfony\Component\Console\Command\Command:
        tags:
            - { name: "console.command" }

    AbstractEntityRepository:
        calls:
            - ["setEntityManager", ["@event_manager"]]

After

Use autoconfigure and _instanceof features.

# app/config/services.yml
services:
    autoconfigure: true 

    Symfony\Component\Console\Command\Command: ~

    _instanceof:
        AbstractEntityRepository:
            calls:
                - ["setEntityManager", ["@event_manager"]]

Minitip

You can also use @required annotation instead of _instanceof in this case, as shared by Kevin Bond - thank you Kevin!

AutoServiceRegistration

This package helped you to register multiple services at once with Finder.

Before

# app/config/config.yml
symplify_auto_service_registration:
    directories_to_scan:
        - %kernel.root_dir%
    class_suffixes_to_seek:
        - Controller

After

Use PSR-4 based service autodiscovery and registration.

# app/config/services.yml

services:
    App\: # no more manual registration of similar groups of services 
        resource: ../{Controller,Command,Subscriber}

Tada!

And just like that, you can drop 4 of Symplify bundles and use Symfony 3.3 happily and safely ever after.


That's all for today. In next post I will show you how to deprecate package without letting anyone behind. Not even your blog readers that could come across and old post about it.



What do you think?