Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
不推荐使用安全批注和Symfony\Component\Security\Core\SecurityContext类_Symfony - Fatal编程技术网

不推荐使用安全批注和Symfony\Component\Security\Core\SecurityContext类

不推荐使用安全批注和Symfony\Component\Security\Core\SecurityContext类,symfony,Symfony,根据Symfony从3.0版开始将删除Symfony\Component\Security\Core\SecurityContext。这里已经讨论了这一点: My symfony报告以下错误: 错误:Symfony\Component\Security\Core\SecurityContext类无效 自版本2.6起已弃用,将在3.0中删除。使用 Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage 或S

根据Symfony从3.0版开始
将删除Symfony\Component\Security\Core\SecurityContext
。这里已经讨论了这一点:

My symfony报告以下错误:

错误:Symfony\Component\Security\Core\SecurityContext类无效 自版本2.6起已弃用,将在3.0中删除。使用 Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage 或Symfony\Component\Security\Core\Authorization\AuthorizationChecker 相反

我正在使用
注释
管理我在symfony中的安全角色,例如

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; // Security annotation bundle

    /**
 * @Route("/account/list", name="Account_list")
 * @Security("has_role('ROLE_USER')")
 */
我应该如何切换到非折旧类?

使用错误中列出的任一类会导致:

[语义错误]方法中的批注“@Security” AppBundle\Controller\AccountController::listAction()从未被 进口的。您是否忘记为此添加“使用”语句 注释?在里面 /var/www/gra.investmentopportunities.pl/src/AppBundle/Controller/ (从中国进口) “/var/www/gra.investmentopportunities.pl/app/config/routing.yml”)

从外观上看,似乎
@security.context
一直使用到
v3.0.4
。从那时起,还注入了
@security.token\u storage
@security.authorization\u checker
,因此,如果它们存在,将使用它们代替
@security.context

从这些事实来看,我只能假设您使用的是
SensioFrameworkExtraBundle
之前的
v3.0.5
版本


如果您的
composer.json
中有
sensio/framework额外捆绑包:~3.0
,那么您可以运行
composer.phar更新sensio/framework额外捆绑包
,它应该将其更新并消除弃用警告。

谢谢您的建议。我已经检查了作曲家,目前正在使用v。sensio/framework额外捆绑包的3.0.9。问题是我应该在脚本头“使用”什么命令才能让注释工作?(请参阅上面更新的代码)。您仍应使用
Sensio\Bundle\FrameworkExtraBundle\Configuration\Security
注释。您确定此弃用警告是由批注引起的吗?自此提交后,仅在其自身上使用
@Security
标记不会发出任何警告-