「Php/Symfony/Symfony2/基本」の版間の差分

提供: 初心者エンジニアの簡易メモ
ナビゲーションに移動 検索に移動
ページの作成:「==リダイレクト(302)== controllerに以下記載。一時的にurlがリダイレクトされる return $this->redirect('/user/1'); ==リダイレクト(301)== con...」
 
編集の要約なし
10行目: 10行目:
controllerに以下記載。画面遷移せずに別のcontrollerを使う
controllerに以下記載。画面遷移せずに別のcontrollerを使う
  return $this->forward("AcmeHelloBundle:User:index");
  return $this->forward("AcmeHelloBundle:User:index");
==リクエスト==
echo $this->getRequest()->query->get('name'); // GET
echo $this->getRequest()->request->get('name'); // POST

2016年12月27日 (火) 04:08時点における版

リダイレクト(302)

controllerに以下記載。一時的にurlがリダイレクトされる

return $this->redirect('/user/1');

リダイレクト(301)

controllerに以下記載。恒久的にurlがリダイレクトされる

return $this->redirect('/user/1', 301);

forward

controllerに以下記載。画面遷移せずに別のcontrollerを使う

return $this->forward("AcmeHelloBundle:User:index");

リクエスト

echo $this->getRequest()->query->get('name'); // GET
echo $this->getRequest()->request->get('name'); // POST