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):
- Acme\OldBundle\OldBundle.php -> NewBundle.php
- 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:
Rename the bundle in
/app/AppKernel.php
From:
$bundles = [ // ... new Acme\OldBundle\AcmeOldBundle(),];
To:
$bundles = [ // ... new Acme\NewBundle\AcmeNewBundle(),];
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
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.
Global configuration files
Search for any occurrence of your old bundle name in
app/config/
and replace it with your new bundle name.