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

Service Container no working "exclude" #50417

Copy link
Copy link
Closed
@Myks92

Description

@Myks92
Issue body actions

Symfony version(s) affected

6.2.8

Description

In version 6.2.8 I get a Service Container error. Files and folders are not excluded. Instead, folders are added to the container as Service ID: [folder/filename] and Class name: [folder/filename]. At the same time, it works on version 6.1.*

Example: https://drive.google.com/file/d/1AfmbLkxpFGtixKnATdKToJUa5x_inl8v/view?usp=share_link
For example, Command, Query, Entity are folders, but they are specified as services in the container.

How to reproduce

Configuration:

src/Kernel.php

<?php

declare(strict_types=1);

namespace App;

use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;

final class Kernel extends BaseKernel
{
    use MicroKernelTrait;

    private function configureContainer(ContainerConfigurator $container): void
    {
        $configDir = $this->getConfigDir();
        $container->import($configDir . '/{packages}/*.{php,yaml}');
        $container->import($configDir . '/{services}/*.{php,yaml}');
        $container->import('./**/config.{php,yaml}');// import config from module
    }
}

src/Auth/config.php

<?php

declare(strict_types=1);

namespace App\Auth;

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

return static function (ContainerConfigurator $configurator): void {
    $services = $configurator
        ->services()
        ->defaults()
        ->autowire()
        ->autoconfigure();

    $services->load('App\\Auth\\', '.')->exclude([
        './config.php',
        './Command',
        './Entity',
        './Query',
        './Test',
        './Validator/Constraint',
    ]);

    $services->load('App\\Auth\\Command\\', './Command/**/Handler.php');
    $services->load('App\\Auth\\Entity\\', './Entity/**/*Repository.php');
    $services->load('App\\Auth\\Query\\', './Query/**/Handler.php');
};

config
Global file services.yaml not used.

Example App: https://github.com/Myks92/symfony-service-container/tree/master

Possible Solution

No response

Additional Context

No response

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.