pok*_*net 5 access-control package deprecated symfony
(在 Symfony 5.4 PHP 7.4 项目上)
到目前为止,我正在使用IsGranted限制每个角色的控制器访问。IE
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted
class PostController extends Controller
{
/**
* @IsGranted("ROLE_ADMIN")
*/
public function myAdminPage()
{ // ... }
}
Run Code Online (Sandbox Code Playgroud)
自从ieabandoned上出现警告以来composer update:
Package sensio/framework-extra-bundle is abandoned, you should avoid using it. Use Symfony instead.我正在尝试寻找替代方案。
对于注释的情况,Route通过将以下内容替换为直接即可
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
:
use Symfony\Component\Routing\Annotation\Route;
但我找不到替代方案IsGranted。(适用于 Symfony 5 或 Symfony 6)
有什么建议/建议吗?
谢谢。
这 :
use Symfony\Component\Security\Http\Attribute\IsGranted;
Run Code Online (Sandbox Code Playgroud)
https://symfony.com/doc/current/security.html#secure-controllers-and-other-code