Skip to content

Bundle auto-registration uses a literal text match, missing bundles that extend an intermediate base #1094

Description

@tacman

For a type: symfony-bundle package without a recipe, Flex auto-registers it in config/bundles.php only if the concrete class file literally contains Symfony\Component\HttpKernel\Bundle\Bundle or ...\AbstractBundle — a raw str_contains() on the file bytes, no autoloading or reflection:

https://github.com/symfony/flex/blob/v2.11.0/src/SymfonyBundle.php#L109-L113

So a bundle extending an intermediate base (e.g. class MyBundle extends AbstractMyVendorBundle, where the vendor base extends AbstractBundle) has neither literal in its own file and is silently skipped — composer req installs it but never updates config/bundles.php. The check also doesn't match the Symfony 8 base Symfony\Component\DependencyInjection\Kernel\AbstractBundle.

I'd argue type: symfony-bundle should be enough on its own. Options for a PR:

  1. Reflection — at install time the class is autoloadable, so check is_subclass_of($class, BundleInterface::class). Robust against intermediate bases and namespace moves.
  2. Remove the heuristic — trust the symfony-bundle type.
  3. Fail loudly — if the package's class doesn't resolve to a BundleInterface, throw rather than silently skipping.

Happy to make a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions