【问题标题】:error 'No route found' Symfony PHP错误'找不到路由' Symfony PHP
【发布时间】:2023-03-29 14:10:02
【问题描述】:

我有这个错误:

[2016-05-12 23:33:48] request.ERROR:未捕获的 PHP 异常 Symfony\Component\HttpKernel\Exception\NotFoundHttpException:“在 /membri/letsolveit 处找不到“GET /lucky/number2”的路由” /vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php line 123 {"exception":"[object] (Symfony\Component\HttpKernel\Exception\NotFoundHttpException(code: 0): 找不到路由在 /membri/letsolveit/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php:123,Symfony\Component\Routing\Exception\ResourceNotFoundException(代码: 0): 在 /membri/letsolveit/var/cache/prod/appProdUrlMatcher.php:39)"} []

如果代码在我的本地机器上完美运行,怎么可能?

这是我的控制器的代码:

<?php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class testController2 extends Controller
{
    /**
     * @Route("/lucky/number2")
     */
    public function numberAction() {
         return new Response('<html><body>Result: test</body></html>');
    }
}

这些是路由文件:

routing_dev.yml:

    _wdt:
    resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
    prefix:   /_wdt

_profiler:
    resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
    prefix:   /_profiler

_errors:
    resource: "@TwigBundle/Resources/config/routing/errors.xml"
    prefix:   /_error

_main:
    resource: routing.yml

routing.yml:

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

有什么问题?

谢谢

【问题讨论】:

  • 你查过php bin/console debug:router说什么了吗?

标签: php controller routing symfony


【解决方案1】:

问题已解决:我删除了缓存文件夹,现在它可以正常工作了!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-08-22
    • 2017-12-29
    • 2020-12-11
    • 2016-07-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多