【发布时间】: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