1

我是 Symfony 的新手,如果我的问题真的很明显,我很抱歉。我正在使用 Symfony 3.4.2。

我的文件app/config/routing.yml

app:
path: /calculator/{age}
defaults: {_controller: AppBundle:Calculator:index}

和文件src/AppBundle/Controller/CalculatorController.php

<?php

namespace AppBundle\Controller;

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

class CalculatorController extends Controller
{
    public function indexAction($age)
    {
        $currentYear = date ('Y');
        return new Response('<html><body>Current year: ' . $currentYear . '<br/>Year of birth: ' . ($currentYear - $age) . '</body></html>');
     }
}

我刚刚修复了 3.4.2 中遇到的一个错误:https ://github.com/symfony/symfony/pull/25523

但是现在,当我尝试通过http://localhost:8000/test_project/web/app_dev.php/calculator/20运行我的应用程序时

我没有找到“GET /test_project/web/app_dev.php/calculator/20”的路线

未捕获的 PHP 异常 Symfony\Component\HttpKernel\Exception\NotFoundHttpException:“在 D:\netbeans-projects\symfony3\test-project\vendor\ 中找不到“GET /test_project/web/app_dev.php/calculator/20”的路由” symfony\symfony\src\Symfony\Component\HttpKernel\EventListener\RouterListener.php 第 139 行

4

0 回答 0