symfony - 在 src/之外创建一个 Bundle

标签 symfony bundle src

我已经使用 symfony 2.3 创建了一个 bundle ,但在这种情况下(因为我的老师要求我)在 src/ 文件夹之外,所以我有 ../symfony/fuentes/NameBundle 而不是 ../symfony/src/NameBundle。新行出现在 AppKernel 中,我的新包出现在 routing.yml 上,但是当我尝试启动服务器时

Bundle generation

Generating the bundle code: OK
Checking that the bundle is autoloaded: FAILED
Confirm automatic update of your Kernel [yes]?
Enabling the bundle inside the Kernel: OK
Confirm automatic update of the Routing [yes]?
Importing the bundle routing resource: OK

The command was not able to configure everything automatically.
You must do the following changes manually.

- Edit the composer.json file and register the bundle
  namespace in the "autoload" section:

我已经编辑自动加载并尝试了很多东西(在这里寻找),但总是出现相同的错误。

C:\Users\Akenateb\Documents\UOC\AULAMENTOR\Symfony>php app/console server:run 127.0.0.1:8080
PHP Fatal error:  Class 'AulaMentor\ExdosBundle\AulaMentorExdosBundle' not found in C:\Users\Akenateb\Documents\UOC\AULAMENTOR\Symfony\app\AppKernel.php on line 20

有人可以帮助我吗?我真的被它困住了。 提前致谢。

最佳答案

首先我要感谢回答的人。如果我们想在“src”文件夹之外创建一个包,例如在“fuentes”>“..Symfony/fuentes”中,那么我们必须执行以下操作。

如果您使用“generate:bundle”创建,我建议您在生成器询问您是否要创建完整结构时接受,如果您使用生成器创建包,请转到步骤 3。

1-确保您已在 AppKernel 中注册了 bundle ,并且它存在于如下行中:

new YourProject\NameprojectBundle\YourProjectNameprojectBundle(),

2- 确保您已将路由添加到您的 app/config/routing 并且“routing.yml”具有新的 bundle 路由,如下所示(您可以向您的 url 添加前缀,在本例中为 fuentes):

您的项目名称:
资源:“@YourProjectNameprojectBundle/Resources/config/routing.yml”
前缀:/fuentes

3-我们编辑“app/autoload.php”并添加以下行:

$loader->add('YourProject',realpath(__DIR__.'/../fuentes'));

最后我们可以使用命令行更新 Assets : php 应用程序/控制台 Assets :安装 web

希望对某人有帮助。
谨致问候。

关于symfony - 在 src/之外创建一个 Bundle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33391274/

相关文章:

Android:将 savedInstanceState 与 fragment 一起使用

javascript - 在移动设备上加载页面后更改 <audio> src 后没有声音播放

Jquery 将 img src 与字符串交换? + 网址编码

caching - Symfony2 : Private ESI Fragment

php - 如何解决 Composer 更新的 ubuntu php 版本

php - Symfony2 唯一 token 生成器

asp.net - 在 ASP.NET 中 bundle 单个文件的成本/ yield 是什么?

java - 如何让 Eclipse 知道 Maven 存储库中的 OSGI 包(本地和|远程)

jquery - 从 elements 属性中替换 img src

php - 如何在 Symfony2 中创建禁止响应?