symfony-url(annotations)

361 查看

symfony 3.1.1 requirements

<?php

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

class DefaultController extends Controller
{
    /**
     * @Route("/", name="homepage")
     */
   /* public function indexAction(Request $request)
    {
        // replace this example code with whatever you need
        return $this->render('default/index.html.twig', [
            'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..'),
        ]);
    }*/

    /**
     * @Route("/wr/{name}",defaults={"name":1},requirements={"name"="\d+"})
     * @Template("default/wr.html.twig")
     */
    public function wrAction($name)
    {
        return array('name' => $name);
    }
}