I'm trying to get started with Symfony2 and I'm getting stuck on the "create your first page" tutorial : http://symfony.com/doc/current/book/page_creation.html
I created the controller file (copy-pasted from tutorial) as E:\Web\project\src\AppBundle\Controller\LuckyController.php :
<?php
// src/AppBundle/Controller/LuckyController.php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;
class LuckyController
{
/**
* @Route("/lucky/number")
*/
public function numberAction()
{
$number = rand(0, 100);
return new Response(
'<html><body>Lucky number: '.$number.'</body></html>'
);
}
}
I didn't make any change to any other file.
When I go to the URL 127.0.0.1/project/web/app_dev.php/lucky/controller (127.0.0.1 is the virtual host for E:\Web) I keep getting the error "No route found for "GET /lucky/controller"".
404 Not Found - NotFoundHttpException
1 linked Exception:
[2/2] NotFoundHttpException: No route found for "GET /lucky/controller/"
[1/2] ResourceNotFoundException:
If I remove the "/web" from the URL, 127.0.0.1/project/app_dev.php/lucky/controller, I get a 404 error.
I'm pretty sure the error comes from the folder structure since the files are unmodified. Similar issue was reported here but none of these suggestions solved my error.