[Symfony 5] Services are private by default

Created on 7 December 2020, almost 4 years ago
Updated 27 May 2024, 6 months ago

Problem/Motivation

Since Symfony 5.2, services in the container are fully private by default and the setPrivate() method has been deprecated.

Steps to reproduce

Update symfony/dependency-injection to 5.2 and see the tests fail.

Proposed resolution

Force services to public if not otherwise specified at container build time.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Fixed

Version

9.2

Component
BaseΒ  β†’

Last updated about 10 hours ago

Created by

πŸ‡¬πŸ‡§United Kingdom longwave UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡©πŸ‡ͺGermany donquixote

    I just ran into this.
    I am trying to use the automatic discovery feature from symfony, to discover services in a module and in some composer packages.
    This feature relies on unused services and aliases being removed, which only works if they are private.

    The ->setPublic(TRUE) in ->setAlias() makes this quite difficult.

  • πŸ‡©πŸ‡ͺGermany donquixote

    The ->setPublic(TRUE) in ->setAlias() makes this quite difficult.

    Actually it is possible by replacing the relevant aliases with a custom class 'ResilientAlias extends Alias', which refuses to be made public.
    I will probably publish something which does this.
    Anyway I still think the implementation from this issue is quite aggressive..

Production build 0.71.5 2024