gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 01:31:14 29 4
gpt4 key购买 nike

我有一个 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/

    29 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com