Skip to content

[DependencyInjection] Attribute to define service aliases #49323

@fbourigault

Description

@fbourigault

Description

Defining services aliases is currently not possible using attributes.

This could be achieved by adding an Alias attribute to the DI component.

Example

Before:

services:
    App\Services\MyInterface: '@App\Services\MyService'

After:

namespace App\Services;

use Symfony\Component\DependencyInjection\Attribute\Alias;

#[Alias(MyInterface::class)]
class MyService implements MyInterface
{

}

Is it something that could be in Symfony?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions