How to rename a bundle in symfony? How to rename a bundle in symfony? symfony symfony

How to rename a bundle in symfony?


I have just completed renaming a bundle myself and ended up at the exact same point as you did a couple of minutes ago. To this point I have used my editors replace-function. It turns out there are some files that need some extra care, which are located here (assuming your old Bundle name was AcmeOldBundle, new will be AcmeNewBundle):

  1. Acme\OldBundle\OldBundle.php -> NewBundle.php
  2. Acme\OldBundle\DependencyInjection\AcmeOldExtension.php ->AcmeNewExtension.php

Do not forget to update the class-names inside the files as well.


The current answers do indeed explain what to do to rename a bundle but they leave out a few things:

  1. Rename the bundle in /app/AppKernel.php

    From:

    $bundles = [    // ...    new Acme\OldBundle\AcmeOldBundle(),];

    To:

    $bundles = [    // ...    new Acme\NewBundle\AcmeNewBundle(),];
  2. Renaming files and folders

    You need to rename the files and folders containing your code:

    src/Acme/OldBundle -> src/Acme/NewBundlesrc/Acme/OldBundle/OldBundle.php -> src/Acme/NewBundle/NewBundle.php# If presentsrc/Acme/OldBundle/DependencyInjection/AcmeOldExtension.php -> src/Acme/NewBundle/DependencyInjection/AcmeNewExtension.php
  3. Namespaces

    This will probably go with forgetting a few files and searching around your bundle for each and every match. The best thing to do is doing a find-replace:

    # find -> replaceacme_old -> acme_newAcme\OldBundle\ -> Acme\NewBundleAcmeOld -> AcmeNewAcme:Old -> Acme:NewAcme:OldBundle -> Acme:NewBundle

    Be sure to check all namespaces, class names and configuration files in your bundle.

  4. Global configuration files

    Search for any occurrence of your old bundle name in app/config/ and replace it with your new bundle name.


You need to update the entire namespace in each files.

You were using namespace Cynergy\ComponentBundle\Something; but you're now using namespace XXXCynergy\ComponentBundle\Something;

Don't forget to update your services.(xml|yml).