src/PHPDish/Bundle/WebBundle/Controller/SearchController.php
public function searchAction(Request $request)
    {
        $keyword = $request->query->get('q');
        $type = $request->query->get('type', static::TYPE_TOPIC);
        $searchResult = $this->searcFrom($keyword, $type, [
            'length' => 10,
            'page' => $request->query->getInt('page', 1)
        ]);
        return $this->render('PHPDishWebBundle:Search:result.html.twig', [
            'searchResult' => $searchResult,
            'keyword' => $keyword
        ]);
    }
public function searchAction(Request $request)
    {
        $keyword = $request->query->get('q');
        $type = $request->query->get('type', static::TYPE_TOPIC);
        $searchResult = $this->searcFrom($keyword, $type, [
            'length' => 10,
            'page' => $request->query->getInt('page', 1)
        ]);
        return $this->render('PHPDishWebBundle:Search:result.html.twig', [
            'searchResult' => $searchResult,
            'keyword' => $keyword
        ]);
    }
搜索页面

@Route("/search", name="search")
@param Request $request
@return Response