Symfony
sponsored by SensioLabs
Menu
  • About
  • Documentation
  • Screencasts
  • Cloud
  • Certification
  • Community
  • Businesses
  • News
  • Download
  1. Home
  2. Documentation
  3. Bundles
  4. How to Remove a Bundle
  • Documentation
  • Book
  • Reference
  • Bundles
  • Cloud
Search by Algolia

Table of Contents

  • 1. Unregister the Bundle in the AppKernel
  • 2. Remove Bundle Configuration
    • 2.1 Remove Bundle Routing
    • 2.2 Remove Bundle Configuration
  • 3. Remove the Bundle from the Filesystem
    • 3.1 Remove Bundle Assets
  • 4. Remove Integration in other Bundles

How to Remove a Bundle

Edit this page

Warning: You are browsing the documentation for Symfony 2.7, which is no longer maintained.

Read the updated version of this page for Symfony 6.2 (the current stable version).

How to Remove a Bundle

1. Unregister the Bundle in the AppKernel

To disconnect the bundle from the framework, you should remove the bundle from the AppKernel::registerBundles() method. The bundle will likely be found in the $bundles array declaration or added to it in a later statement if the bundle is only registered in the development environment:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            new Acme\DemoBundle\AcmeDemoBundle(),
        );

        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            // comment or remove this line:
            // $bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
            // ...
        }
    }
}

2. Remove Bundle Configuration

Now that Symfony doesn't know about the bundle, you need to remove any configuration and routing configuration inside the app/config directory that refers to the bundle.

2.1 Remove Bundle Routing

Some bundles require you to import routing configuration. Check for references to the bundle in app/config/routing.yml and app/config/routing_dev.yml. If you find any references, remove them completely.

2.2 Remove Bundle Configuration

Some bundles contain configuration in one of the app/config/config*.yml files. Be sure to remove the related configuration from these files. You can quickly spot bundle configuration by looking for an acme_demo (or whatever the name of the bundle is, e.g. fos_user for the FOSUserBundle) string in the configuration files.

3. Remove the Bundle from the Filesystem

Now you have removed every reference to the bundle in your application, you should remove the bundle from the filesystem. The bundle will be located in `src/` for example the src/Acme/DemoBundle directory. You should remove this directory, and any parent directories that are now empty (e.g. src/Acme/).

Tip

If you don't know the location of a bundle, you can use the getPath() method to get the path of the bundle:

1
2
dump($this->container->get('kernel')->getBundle('AcmeDemoBundle')->getPath());
die();

3.1 Remove Bundle Assets

Remove the assets of the bundle in the web/ directory (e.g. web/bundles/acmedemo for the AcmeDemoBundle).

4. Remove Integration in other Bundles

Some bundles rely on other bundles, if you remove one of the two, the other will probably not work. Be sure that no other bundles, third party or self-made, rely on the bundle you are about to remove.

Tip

If one bundle relies on another, in most cases it means that it uses some services from the bundle. Searching for the bundle alias string may help you spot them (e.g. acme_demo for bundles depending on AcmeDemoBundle).

Tip

If a third party bundle relies on another bundle, you can find that bundle mentioned in the composer.json file included in the bundle directory.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
We stand with Ukraine.
Version:
Check Code Performance in Dev, Test, Staging & Production

Check Code Performance in Dev, Test, Staging & Production

Peruse our complete Symfony & PHP solutions catalog for your web development needs.

Peruse our complete Symfony & PHP solutions catalog for your web development needs.

↓ Our footer now uses the colors of the Ukrainian flag because Symfony stands with the people of Ukraine.

Avatar of Lukas W, a Symfony contributor

Thanks Lukas W for being a Symfony contributor

1 commit • 1 lines changed

View all contributors that help us make Symfony

Become a Symfony contributor

Be an active part of the community and contribute ideas, code and bug fixes. Both experts and newcomers are welcome.

Learn how to contribute

Symfony™ is a trademark of Symfony SAS. All rights reserved.

  • What is Symfony?
    • Symfony at a Glance
    • Symfony Components
    • Case Studies
    • Symfony Releases
    • Security Policy
    • Logo & Screenshots
    • Trademark & Licenses
    • symfony1 Legacy
  • Learn Symfony
    • Symfony Docs
    • Symfony Book
    • Reference
    • Bundles
    • Best Practices
    • Training
    • eLearning Platform
    • Certification
  • Screencasts
    • Learn Symfony
    • Learn PHP
    • Learn JavaScript
    • Learn Drupal
    • Learn RESTful APIs
  • Community
    • SymfonyConnect
    • Support
    • How to be Involved
    • Code of Conduct
    • Events & Meetups
    • Projects using Symfony
    • Downloads Stats
    • Contributors
    • Backers
  • Blog
    • Events & Meetups
    • A week of symfony
    • Case studies
    • Cloud
    • Community
    • Conferences
    • Diversity
    • Documentation
    • Living on the edge
    • Releases
    • Security Advisories
    • SymfonyInsight
    • Twig
    • SensioLabs
  • Services
    • SensioLabs services
    • Train developers
    • Manage your project quality
    • Improve your project performance
    • Host Symfony projects
    Deployed on
Follow Symfony
Search by Algolia