Symfony 3 路由:找不到 "GET /user/add" 的路由

Symfony 3 Routing: No route found for "GET /user/add"

我正在开发一个简单的用户应用程序来练习 Symfony (3.1.3)。 我创建了一个新的 Bundle,

//pie10-api/api/src/PIE10Bundle/Controller/BackendUmController.php

<?php

namespace PIE10Bundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;

class BackendUmController extends Controller
{
    /**
     * @Route("/user")
     */
    public function indexAction()
    {
        // nothing for now
    }

    /**
     * @Route("/user/add")
     */
    public function adduserAction()
    {
        return $this->render('PIE10Bundle:users:layout_new_user.html.twig');
    }
}

并在

上创建了一个测试视图

//pie10-api/api/src/PIE10Bundle/Resources/views/users/layout_new_user.html.twig

当我尝试使用以下 URL、

访问它时

http://localhost/app/web/app_dev.php/user/add

它给出以下 404 错误

找不到 "GET /user/add" 的路线

并且我尝试了一些在线解决方案,例如清除缓存...但无法解决这个问题,我需要有人帮忙解决这个错误。

如果需要与我的开发相关的任何其他信息,请告诉我。

你有添加吗app/config/routing.yml

app:
    resource: "@PIE10Bundle/Controller/"
    type:     annotation

你必须检查这个 (name="foo")。

/**
 * @Route("/", name="homepage")
 */
public function adduserAction(Request $request)
{
    // replace this example code with whatever you need
}