Skip to content

[DI][Proposal] Support anonymous classes in service definition #20997

Closed
@skafandri

Description

@skafandri
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? yes
Symfony version master

I don't know if this actually makes sense as a way to make defining services easier. The idea is to be able to define a service only in a config. Without the need to define a class.

Example in yml:

var_dump_logger: >
        new class extends \Psr\Log\AbstractLogger {
        
            public function log($level, $message, array $context = array())
            {
                var_dump(['level' => $level, 'message' => $message, 'context' => $context]);
            }
        };

I don't think is a good way to define services, rather a quick way to play around with the DI component.

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