megogo/multiple-inheritance-bundle
Symfony bundle that brings multiple inheritance to PHP, letting classes inherit behavior from several parent classes at once. Helps share reusable logic across services without duplication. Installs via Composer and integrates with Symfony's service container.
Bundle::getParent() returns a single class) by letting several child bundles share/consume one or more parent bundles' resources (templates, translations, routes, DI config). It is archived, 5 stars, and has no dependents — treat it as legacy code you maintain, not a dependency you expect fixes from.composer require megogo/multiple-inheritance-bundle. Pin the version in composer.json ("megogo/multiple-inheritance-bundle": "dev-master" or a tagged release) since there will be no upstream patches. Verify the composer.json of the bundle for its symfony/symfony constraint before installing; it will not resolve cleanly against Symfony 3+.app/AppKernel.php::registerBundles(). Register it before the bundles that use it, and register parent bundles before children.Bundle class and README. The integration point is the class you extend (or interface you implement) for your child bundle — it lets you declare multiple parents instead of Symfony's single getParent(). Read the compiler pass / kernel hook in the bundle source to understand when the parent chain is resolved (before or after registerBundles).AdminBundle and FrontendBundle that both need the same layout templates, form themes, translations, and a handful of shared services currently living in BaseBundle. With vanilla Symfony you can only pick one parent. Use this bundle to declare BaseBundle (plus any second parent) once and let both child bundles inherit from it.BaseBundle holding layouts, macros, common translations, and shared services. Each child bundle declares its parent(s) via the bundle's multi-parent mechanism instead of overriding getParent(). You then delete the duplicated Resources/views/ trees from the children.Resources/ wins, then parents in declaration order. Keep a one-line comment in each override header documenting which parent it shadows — this is the only documentation you'll get.BaseBundle → ApiBundle and BaseBundle → WebBundle, with a third DebugBundle parent added only in dev. Keep such conditional registration in AppKernel guarded by $this->getEnvironment(), and clear the cache when switching environments.services.yml/config.yml, remember Symfony's Extension::load() convention: later-loaded config overrides earlier for scalars, but arrays/parameters merge per Symfony's rules. Prefer explicit parameter namespacing (base.foo, admin.foo) over relying on implicit merge order./base, /admin). Test with app/console router:debug after wiring; duplicate route names silently shadow.messages, admin, base) rather than per-bundle catalogs to avoid collisions.getParent(). Introduce the bundle by keeping existing single-parent behavior first (declare one parent through the new mechanism), confirm nothing breaks, then add the second parent. This isolates "did the bundle break my app?" from "did my second parent break my app?"AppBaseBundle so a future replacement (composer symfony/asset-style manual includes, or a custom kernel Bundle subclass) only touches one file.Kernel::registerBundles, Bundle::getParent). Do not attempt to upgrade a project that depends on it; plan the rewrite instead.AppKernel.app/console cache:clear --env=dev (and --env=prod if you deploy) before debugging — half of "it's not inheriting" reports are stale cache.app/console container:debug <service> for service visibility, router:debug for routes, debug:translation <locale> for catalog merging, and a raw var_dump($this->getBundles()) inside a controller to see the resolved bundle list and order. Also check app/cache/dev/appDevDebugProjectContainer.xml to see which resource paths actually got registered.repositories VCS entry.AppKernel. Keep it in a suite that CI runs, because nobody upstream will tell you when it breaks.includes and explicit service imports — more verbose, but future-proof against Symfony 4+.How can I help you explore Laravel packages today?