Skip to content

Use FileLoader::registerClasses() in PHP configuration examples #7922

Closed
@weaverryan

Description

@weaverryan

So far, if we're using the PSR4 loader in a YAML or XML code block, in PHP, we say something like "this is not possible". For example: the configuration-block under https://github.com/symfony/symfony-docs/blob/80138cacba5604398aafb54c3cde1117529d6817/service_container.rst#creatingconfiguring-services-in-the-container.

But actually, @nicolas-grekas pointed out that this is not correct! In a PHP file, I believe the $this variable should be an instance of the PhpFileLoader. So we should be able to do:

$definition = new Definition();
$this->registerClasses($definition, 'AppBundle\\', '../../src/AppBundle/*', '../../src/AppBundle/{Entity,Repository}');

Let's update all the examples with this on the 3.3 branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DependencyInjectionbughasPRA Pull Request has already been submitted for this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions