Skip to content

Define alias with an attribute #41188

Closed
Closed
@garak

Description

@garak

Description

Scenario: you have a concrete class that implements an interface. Currently, you need to add an alias in your services configuration,
The idea is to avoid it with a new php8 attribute, that can be applied to the class.

Example

<?php

namespace Foo;

use Symfony\Component\DependencyInjection\Attribute\Alias;

#[Alias]
final class MyClass implements \Bar\MyInterface
{
    // ...
}

the following then can be avoided:

services:
    Bar\MyInterface: '@Foo\MyClass'

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy