// src/AppBundle/Controller/LuckyController.php
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;
class LuckyController extends Controller
{
/**
* @Route("/lucky/number")
*/
public function numberAction()
{
$number = rand(0, 100);
return new Response(
'<html><body>Lucky number: '.$number.'</body></html>'
);
}
}
I'm new of Symfony framework. I tried this simple code without any result. That's the server response:
No route found for "GET /lucky/number" 404 Not Found - NotFoundHttpException 1 linked Exception: ResourceNotFoundException »
I don't now why the Default controller use the annotation and I can see the homepage of my Symfony application.
/app_dev.php/lucky/number
? If you don't, you would need to clear the cache of the production environment:$ php app/console cache:clear --env=prod
. – D4V1D