在 Symfony 2.4.1 中移除 AcmeDemoBundle 需手动操作:删 AppKernel.php 注册、删 src/Acme/DemoBundle 目录、清 config_dev.yml 和 routing_dev.yml 中相关配置、清缓存、验证路由 404 且 router:debug 无输出,并检查 use 语句、autoload 映射及前端资源。

在 Symfony 2.4.1 中移除 AcmeDemoBundle 是一个手动清理过程,因为该版本尚未引入 Flex 或自动 bundle 管理机制,也没有 composer remove 命令支持。
确认 AcmeDemoBundle 已启用
检查 app/AppKernel.php 文件中是否注册了该 Bundle:
- 打开
app/AppKernel.php - 查找类似
new AcmeDemoBundleAcmeDemoBundle()的行 - 若存在,直接删除这一行
删除源码和配置文件
AcmeDemoBundle 通常位于 src/Acme/DemoBundle/,需彻底清除:
- 删除整个目录:
rm -rf src/Acme/DemoBundle - 检查
app/config/config_dev.yml,移除对acme_demo的引用(如imports:或framework.router:相关路由配置) - 检查
app/config/routing_dev.yml,删除类似_acme_demo: resource: "@AcmeDemoBundle/Resources/config/routing.yml"的路由导入
清理缓存并验证
Bundle 移除后必须清空缓存,否则可能因类加载或路由残留导致异常:
- 运行
php app/console cache:clear --env=dev - 再运行
php app/console cache:clear --env=prod(如果已部署) - 访问
/demo或/_demo路由,确认返回 404 - 执行
php app/console router:debug | grep acme,应无任何输出
额外检查点
避免遗漏影响运行的隐性依赖:
- 搜索项目中所有
use AcmeDemoBundle或new AcmeDemoBundle的 PHP 引用,一并删除 - 检查
composer.json的autoload段,确认没有"Acme\": "src/Acme/"类似映射(如有且仅用于 DemoBundle,可安全删减) - 若曾为 DemoBundle 安装过前端资源(如
web/bundles/acmedemo/),也建议手动清理


















