Skip to content

[HttpKernel] [6.1] Bundle path is parent directory instead of bundle directory when using new AbstractBundle #46482

@ruudk

Description

@ruudk

Symfony version(s) affected

6.1.0

Description

When using the new AbstractBundle introduced in Symfony 6.1, the path of the bundle is that of the parent directory which doesn't make any sense to me.

How to reproduce

  • Create src/Shared/Infrastructure/GraphQL directory
  • Create GraphQLBundle.php file in that directory that implements AbstractBundle
  • Try to import routes using @GraphQLBundle/Controller/ and see that it fails

This is because the bundle is registered like this in the Kernel:

  "GraphQLBundle" => Shared\Infrastructure\GraphQL\GraphQLBundle^ {#142
    #name: "GraphQLBundle"
    #extension: Symfony\Component\HttpKernel\Bundle\BundleExtension^ {#6812
      -processedConfigs: []
      -subject: Shared\Infrastructure\GraphQL\GraphQLBundle^ {#142}
      -alias: "graphql"
    }
    #path: "/Volumes/CS/www/website/src/Shared/Infrastructure"
    -namespace: "Shared\Infrastructure\GraphQL"
    #container: null
    #extensionAlias: "graphql"
  }

As you can see, the path property of the bundle is the parent directory src/Shared/Infrastructure

Possible Solution

I think the solution merged in #46385 needs thought.

For now, I need to manually override the path property to fix this. But shouldn't the bundle's path always be the location that specifies the bundle file?

Additional Context

#43701
#46385

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