I installed Symfony4 using the following steps.
step1: composer create-project "Symfony/skeleton:^4.0” symfony4 step2: git status step3: git add. step4: git commit step5: composer require annotations step6: create a controller named ArticleController
<?php
namespace App\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Component\HttpFoundation\Response;
class ArticleController
{
/**
* @Route("/")
*/
public function indexAction()
{
return new Response('OMG! My first page already! Wooooo!');
}
/**
* @Route("/{id}", requirements={"id" = "\d+"}, defaults={"id" = 1})
*/
public function showAction($id)
{
echo 123;die;
}
/**
* @Route("/news/{$slug}")
* @Method({"GET", "POST"})
*/
public function news($slug)
{
return new Response(sprintf('Today new is "%s"', $slug));
}
}
Step7: access http://127.0.0.1:8000 You can view 'OMG! My first page already! Wooooo!'.
But http://127.0.0.1:8000/123 and http://127.0.0.1:8000/news/test do not work. Who can tell me why? And please help me to fix it.