layout |
title |
date |
tags |
permalink |
published |
author |
post |
Renaming a Symfony 2 bundle |
2013-04-09 22:29:48+00:00 |
|
/blog/2013/4/9/renaming-a-symfony-2-bundle |
true |
|
Today I’ve realised that the name I gave to one of my Symfony 2 bundles should
be something else. To rename a bundle, one must do four things (at least).
- Change the namespace from
Vendor\OldBundle
to Vendor\NewBundle
in every
PHP class (sounds like pain? It is…)
- Change the name of files and classes. Some files under
src/Vendor/OldBundle
(and the classes in them) contain the name of the
bundle, like OldBundle/DependencyInjection/VendorOldBundleExtension.php
and OldBundle/VendorOldBundle.php
. You should rename them, or Symfony
won’t find the classes defined in them! When done, rename the whole bundle
directory either.
- Change the configuration files accordingly, including
AppKernel.php
. These
config files are usually routing.yml
, services.yml
, and in some cases,
config.yml
- Change the references in other parts of your code. A
grep OldBundle .
will
usually help…