php - 在 Symfony2 中创建 Bundle 后出现 FileLoaderImportCircularReferenceException

标签 php symfony symfony-2.6 symfony-routing

我是 Symfony 开发的新手,我已经创建了我的第一个项目和第一个使用命令行 php app\console generate:bundle 的 bundle。

通常,我应该能够使用这个新包并访问 URL hello/{name},但是当我尝试访问 URL http://localhost/mylibrary-web/web/app_dev.php/hello/test/ 时我收到此错误消息:

FileLoader.php 第 97 行中的 FileLoaderImportCircularReferenceException:在“C:\wamp\www\mylibrary-web\app/config/routing_dev.yml”中检测到循环引用(“C:\wamp\www\mylibrary-web\app/config/routing_dev.yml"> "C:\wamp\www\mylibrary-web\app/config\routing.yml"> "C:\wamp\www\mylibrary-web\app/config/routing_dev.yml ”)。

我该如何解决这个问题?

这里是我项目的路由文件:

C:\wamp\www\mylibrary-web\app\config\routing_dev.yml :

_wdt:
    resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
    prefix:   /_wdt

_profiler:
    resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
    prefix:   /_profiler

_configurator:
    resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
    prefix:   /_configurator

_errors:
    resource: "@TwigBundle/Resources/config/routing/errors.xml"
    prefix:   /_error

_main:
    resource: routing.yml

C:\wamp\www\mylibrary-web\app\config\routing.yml :

my_library_library:
    resource: "@MyLibraryLibraryBundle/Resources/config/routing.yml"
    prefix:   /

app:
    resource: "@AppBundle/Controller/"
    type:     annotation

C:\wamp\www\mylibrary-web\src\MyLibrary\LibraryBundle\Resources\config\routing.yml :

my_library_library_homepage:
    path:     /hello/{name}
    defaults: { _controller: MyLibraryLibraryBundle:Default:index }

感谢您的帮助!

编辑:这里是命令行 php app\console debug:router 的结果:

C:\wamp\www\mylibrary-web>php app\console debug:router
[router] Current routes
 Name                        Method Scheme Host Path
 _wdt                        ANY    ANY    ANY  /_wdt/{token}
 _profiler_home              ANY    ANY    ANY  /_profiler/
 _profiler_search            ANY    ANY    ANY  /_profiler/search
 _profiler_search_bar        ANY    ANY    ANY  /_profiler/search_bar
 _profiler_purge             ANY    ANY    ANY  /_profiler/purge
 _profiler_info              ANY    ANY    ANY  /_profiler/info/{about}
 _profiler_phpinfo           ANY    ANY    ANY  /_profiler/phpinfo
 _profiler_search_results    ANY    ANY    ANY  /_profiler/{token}/search/results
 _profiler                   ANY    ANY    ANY  /_profiler/{token}
 _profiler_router            ANY    ANY    ANY  /_profiler/{token}/router
 _profiler_exception         ANY    ANY    ANY  /_profiler/{token}/exception
 _profiler_exception_css     ANY    ANY    ANY  /_profiler/{token}/exception.css
 _configurator_home          ANY    ANY    ANY  /_configurator/
 _configurator_step          ANY    ANY    ANY  /_configurator/step/{index}
 _configurator_final         ANY    ANY    ANY  /_configurator/final
 _twig_error_test            ANY    ANY    ANY  /_error/{code}.{_format}
 my_library_library_homepage ANY    ANY    ANY  /hello/{name}
 homepage                    ANY    ANY    ANY  /app/example

编辑 2:使用命令行 php app\console cache:clear 清除缓存后,我现在有以下错误:

ContextErrorException in classes.php line 6415: Warning: filemtime(): stat failed for C:\wamp\www\mylibrary-web\app\cache\dev/annotations/597877fc1359850fa8786ead82dcc8f6f491d628.cache.php

最佳答案

我终于找到了解决方案...问题来自 OPCache 和以下设置:opcache.enable_file_override=1。使用 opcache.enable_file_override=0 更改后一切正常:)

关于php - 在 Symfony2 中创建 Bundle 后出现 FileLoaderImportCircularReferenceException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29735817/

相关文章:

php - 获取字符串中的第一个字母(该字符串包含阿拉伯字母)

PHP支付库

php - Symfony 2 Sonata Admin Bundle 的表演 Action 不起作用

php - Symfony:LoggingTranslator 与翻译器

symfony - 我可以在 TWIG 基本模板中包含 PHP 模板,反之亦然吗?

php - 我该如何使用 cron?

php - 使用视频ID从PHP API获得YouTube视频质量

symfony - Symfony 2.0 中缓存和日志文件夹中的权限问题

php - 使用 'OR condition' 的 Doctrine FindBy 方法?

security - symfony 安全产品不起作用