My bundle is located at src/Cinergy/Bundle/ComponentBundle/CinergyComponentBundle.php
and the logical name of the bundle is 'CinergyComponentBundle'
.
Since I did not stick to the naming convention of the company I have to change the logcial name of the bundle. Lets asume I have to rename it to 'XXXCinergyComponentBundle'
What files do I need to change?
I tried renaming the CinergyComponentBundle.php
file and the containing class into XXXCinergyComponentBundle.php
. I also changed the reference in AppKernel.
Unfortunately this does not work. When I try to clear the cache I get this error message:
[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
The service "cinergy.people.direct.php" has a dependency on a non-existent service "cinergy.work.registry".
This two services do belong to the bundle with the new name. This leads me to the conclusion that I'm missing something in the renaming process.
Any ideas?
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):
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/NewBundle
src/Acme/OldBundle/OldBundle.php -> src/Acme/NewBundle/NewBundle.php
# If present
src/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 -> replace
acme_old -> acme_new
Acme\OldBundle\ -> Acme\NewBundle
AcmeOld -> AcmeNew
Acme:Old -> Acme:New
Acme: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.
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)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With