Php – error ‘No route found’ Symfony PHP

controllerPHProutingsymfony

I have this error:

[2016-05-12 23:33:48] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /lucky/number2"" at /membri/letsolveit/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php line 123 {"exception":"[object] (Symfony\Component\HttpKernel\Exception\NotFoundHttpException(code: 0): No route found for \"GET /lucky/number2\" at /membri/letsolveit/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php:123, Symfony\Component\Routing\Exception\ResourceNotFoundException(code: 0): at /membri/letsolveit/var/cache/prod/appProdUrlMatcher.php:39)"} []

How is possible if the code works perfectly in my local machine?

this is the code of mine controller:

<?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>');
    }
}

these are routing files:

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

What is the problem?

Thanks

Best Answer

Problem solved: I deleted the cache folder and now it works perfectly!

Related Topic