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

  • Home
  • SEARCH
  • 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 6119429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:33:06+00:00 2026-05-23T15:33:06+00:00

I have a loader bundle ( LoaderBundle ) that should register other bundles in

  • 0

I have a loader bundle (LoaderBundle) that should register other bundles in the same directory.

/Acme/LoaderBundle/...
/Acme/ToBeLoadedBundle1/...
/Acme/ToBeLoadedBundle2/...

I’d like to avoid manually registering every new bundle (in Acme directory) in AppKernel::registerBundles(). Preferably I’d like something in LoaderBundle to run on every single request and dynamically register ToBeLoadedBundle1 and ToBeLoadedBundle2. Is it possible?

  • 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-05-23T15:33:07+00:00Added an answer on May 23, 2026 at 3:33 pm

    Untested but you could try something like

    use Symfony\Component\HttpKernel\Kernel;
    use Symfony\Component\Config\Loader\LoaderInterface;
    use Symfony\Component\Finder\Finder;
    
    class AppKernel extends Kernel
    {
        public function registerBundles()
        {
            $bundles = array(
                new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
                //... default bundles
            );
    
            if (in_array($this->getEnvironment(), array('dev', 'test'))) {
                $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
                // ... debug and development bundles
            }
    
            $searchPath = __DIR__.'/../src';
            $finder     = new Finder();
            $finder->files()
                   ->in($searchPath)
                   ->name('*Bundle.php');
    
            foreach ($finder as $file) {
                $path       = substr($file->getRealpath(), strlen($searchPath) + 1, -4);
                $parts      = explode('/', $path);
                $class      = array_pop($parts);
                $namespace  = implode('\\', $parts);
                $class      = $namespace.'\\'.$class;
                $bundles[]  = new $class();
            }
    
            return $bundles;
        }
    
        public function registerContainerConfiguration(LoaderInterface $loader)
        {
            $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a loader.exe with Main() that loads the 'UI' in WPF, the thing
I have a custom class loader so that a desktop application can dynamically start
I have a list of images that i’ve loaded with the Loader class, but
For example, I have a piece of code that's generating a SQL*Loader control file
If I have a bundle that contains a class and some resources used by
I have a context loader class which loads an XML file with info on
I have a custom class loader which extends from a URLClassLoader. I added a
I have created thumbnail view using Three20 bundle. I have successfully loaded and displayed
I have a NIB that contains a UINavigationController which has a UIViewController . The
I have a small app that from the home screen has a few buttons,

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.