Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[4.1] The "parameter_bag" service is not available. #27436

Copy link
Copy link
Closed
@emulienfou

Description

@emulienfou
Issue body actions

Symfony version(s) affected: 4.1.0

Description
Since updated to Symfony 4.1, I switch to use AbstractController instead of Controller class, as suggested!

However, I receive now the LogicExtension: The "parameter_bag" service is not available. Try running "composer require dependency-injection:^4.1".

It seems the the service parameter_bag is not public and cannot be acceded!

Using the debug command: php bin/console debug:container parameter_bag

Information for Service "parameter_bag"
=======================================

 ---------------- ----------------------------------------------------------------- 
  Option           Value                                                            
 ---------------- ----------------------------------------------------------------- 
  Service ID       parameter_bag                                                    
  Class            Symfony\Component\DependencyInjection\ParameterBag\ContainerBag  
  Tags             -                                                                
  Public           no                                                               
  Synthetic        no                                                               
  Lazy             no                                                               
  Shared           yes                                                              
  Abstract         no                                                               
  Autowired        no                                                               
  Autoconfigured   no                                                               
 ---------------- ----------------------------------------------------------------- 

How to reproduce

class TestController extends AbstractController
{
    public function index()
    {
       // ...
       $variable = $this->getParameter('service_name');
       // ...
    }
}

Possible Solution
In the file: framework-bundle/Resources/config/services.xml

Change:

<service id="parameter_bag" class="Symfony\Component\DependencyInjection\ParameterBag\ContainerBag">
        <argument type="service" id="service_container" />
</service>

By:

<service id="parameter_bag" class="Symfony\Component\DependencyInjection\ParameterBag\ContainerBag" public="true">
        <argument type="service" id="service_container" />
 </service>

To make the service has public seems to resolve the issue!

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.