Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9127121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:12:35+00:00 2026-06-17T07:12:35+00:00

Suppose I have two bundles ParentBundle and ChildBundle . ChildBundle extends ParentBundle by //

  • 0

Suppose I have two bundles ParentBundle and ChildBundle. ChildBundle “extends” ParentBundle by

// ChildBundle/ChildBundle.php
<?php

namespace ChildBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class ChildBundle extends Bundle
{
    public function getParent()
    {
        return 'ParentBundle';
    }

}

Then, I copied the routing from ParentBundle to ChildBundle, and specify which routing to use in app/config/routing.yml, as well as rename the routing.yml as per Symfony2 bundle inheritance losing parent bundles routes

// app/config/routing.yml
child:
    resource: "@ChildBundle/Resources/config/routing_child.yml"
    hostname_pattern: child.example.com
    prefix:   /

parent:
    resource: "@ParentBundle/Resources/config/routing.yml"
    prefix:   /

After that, I create a template in ChildBundle with same path and name, to override the template in ParentBundle of the same name.

However, it results in loading the template in ChildBundle all the time.

So, my problem is, How do I load the ChildBundle in one domain (i.e. use overriding templates/controllers and such in ChildBundle, when user goes into child.example.com) while use ParentBundle in another domain (i.e. use overriden templates/controllers and such in ParentBundle, when user goes into example.com)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:12:37+00:00Added an answer on June 17, 2026 at 7:12 am

    You should read this answer I did: Main page to sub applications on Symfony2

    In fact you have to create 2 controllers in the web folder, for example:
    web/app.php, web/app_child.php

    Inside app_child.php, call a new environnement, here called “child”:

    // ...    
    $kernel = new AppKernel('child', false);
    // ...
    

    Create a config_child.yml that will be specific to child bundle, you can paste here the config.yml content or even import config.yml to prevent duplicate code:

    // config_child.yml
    imports:
        - { resource: config.yml }
    

    Create a new routing file that includes the routes of child bundle, called routing_child.yml for example, and import this file in config_child.php:

    framework:
        router:
            resource: "%kernel.root_dir%/config/routing_child.yml"
    

    Remove the child bundle routes from your classic routing.yml file.

    Now play with your web/.htaccess to call the right environnement depending on the subdomain:

    <IfModule mod_rewrite.c>
        RewriteEngine On
    
        # Hit child app
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{HTTP_HOST} !^child\.example.com$ [NC]
        RewriteRule ^(.*)$ app_child.php [QSA,L]
    
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ app.php [QSA,L]
    </IfModule>
    

    That’s it, now your applciation will load the right routing config depending on the domain 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have two descendants of an abstract class: object Child1 extends MyAbstrClass {
Suppose we have two classes: class Base { private: int x; public: void f();
Suppose I have two methods in my class, methodA and methodB. In methodA, I
Suppose I have two classes: class A(): pass class B(): pass I have another
Suppose i have two methods in a class say public void eat(int i,String s)
Suppose I have two custom classes and a method as follows: class A {
Suppose I have two classes a base class and an inherited class as follows:
Suppose I have two C++ classes: class A { public: A() { fn(); }
Suppose I have two classes with identical members from two different libraries: namespace A
I have two entities: products and bundles. Each one has its class. A product

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.