来自 3.2 的 Symfony 3.3:编译错误:无法声明类 Symfony\Bundle\SecurityBundle\Security\FirewallMap [英] Symfony 3.3 from 3.2: Compile Error: Cannot declare class Symfony\Bundle\SecurityBundle\Security\FirewallMap
问题描述
自从我从 symfony 3.2 更新到 3.3 以来,我遇到了一些问题,我收到了这个错误
I'm experiencing some problems since I updated from symfony 3.2 to 3.3, I got this error
Compile Error: Cannot declare class Symfony\Bundle\SecurityBundle\Security\FirewallMap, because the name is already in use
in classes.php (line 1709)
in ClassCollectionLoader.php (line 99)
at ClassCollectionLoader::load()in Kernel.php (line 428)
at Kernel->doLoadClassCache()in Kernel.php (line 112)
at Kernel->boot()in Kernel.php (line 168)
at Kernel->handle()in app_dev.php (line 12)
at {main}()in app_dev.php (line 0)
这很有趣,因为我只在通过浏览器访问 app_dev.php 时遇到此错误,如果我直接执行
It's interesting because I only got this error accesing app_dev.php through the browser, If I directly exeucte
php app_dev.php
然后错误不会出现,我只是重定向到登录页面,因为我应该
Then the error doesn't appear and I just get redirect to the login page as I am suppossed to
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="refresh" content="1;url=http://:/login" />
<title>Redirecting to http://:/login</title>
</head>
<body>
Redirecting to <a href="http://:/login">http://:/login</a>.
</body>
</html>
命令工作正常,我可以清除缓存,取消路由...
Commands work fine, I can clear the cache, debout routes...
有什么想法吗?
谢谢!
更新:这里是 app_dev.php 的内容
Update: here's the content of the app_dev.php
<?php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;
/** @var \Composer\Autoload\ClassLoader $loader */
$loader = require __DIR__.'/../app/autoload.php';
Debug::enable();
$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
推荐答案
我遇到了可能非常极端的情况,但也许它会对某人有所帮助.在 Twig 模板中,我使用了一个常量,并且在某个时候对对象命名空间中的斜杠进行了双重转义:
I had what is likely very much an edge-case but maybe it will help someone. In a Twig template I was using a constant and had at some point double-escaped the slashes in the object namespace:
{{ constant('App\\Entity\\\\MyClass::MY_CONSTANT') }}
应该是:
{{ constant('App\\Entity\\MyClass::MY_CONSTANT') }}
额外的斜杠导致此错误消息.
The extra slashes were causing this error message.
这篇关于来自 3.2 的 Symfony 3.3:编译错误:无法声明类 Symfony\Bundle\SecurityBundle\Security\FirewallMap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!