symfony - 如何修复 Symfony 3.4 @Route 和 @Method 弃用

标签 symfony routing symfony-3.4 deprecation-warning

我有一个 Symfony 3.4 项目,我在探查器中发现了以下消息:

  • “Sensio\Bundle\FrameworkExtraBundle\Configuration\Route”注释自 5.2 版起已弃用。使用“Symfony\Component\Routing\Annotation\Route”
  • “Sensio\Bundle\FrameworkExtraBundle\Configuration\Method”注释自 5.2 版起已弃用。使用“Symfony\Component\Routing\Annotation\Route”
  • “sensio_framework_extra.router.annotations”配置自 5.2 版起已弃用。将其设置为 false 并使用“Symfony\Component\Routing\Annotation\Route”

  • 我花了一些时间寻找解决方案,但没有发现任何真正有用的东西。
    一些发现 herehere .

    最佳答案

    替换这个:

    use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
    use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
    
    class UserController
        {
        /**
         * @Route("/users")
         * @Method("GET")
         */
        public action index()
            {}
    

    有了这个:
    use Symfony\Component\Routing\Annotation\Route;
    class UserController
        {
        /**
         * @Route(path="/users", methods={"GET"})
         */
    

    H/T 这家伙 -> https://medium.com/@nebkam/symfony-deprecated-route-and-method-annotations-4d5e1d34556a

    关于symfony - 如何修复 Symfony 3.4 @Route 和 @Method 弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51171934/

    相关文章:

    composer-php - 由于 composer 权限问题,Symfony 无法安装新包

    Symfony 验证 : range between two numbers, 或一个值

    symfony - 具有数据库连接依赖关系的自定义约束验证器 Symfony2

    ruby-on-rails - 如何使 Rails 3 路由器使用本地化文件本地化 URL?

    asp.net-web-api - 如何使用OWIN自托管的Web API来提供index.html

    c# - 如何使用 OpenStreetMap 获取两点之间的距离

    javascript - 直到我在 Firebug 中设置断点后,jQuery 才会执行

    symfony - 修改请求参数值

    symfony - 使用表单时不会调用魔术方法 __call

    php - 如何在 Symfony3.4 中清除 Controller 中的缓存?