Last active
June 1, 2019 13:30
-
-
Save NakanoMakoto/52b5dfd184caaf206a20f438f1e51605 to your computer and use it in GitHub Desktop.
Symfony-beginner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DefaultController extends Controller | |
{ | |
\** | |
* @Route("/", name="homepage") | |
*\ | |
public function indexAction() { | |
return $this->render("index.html.twig",[]); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% for message in app.flashes("notice")%} | |
<div class="flash-notice"> | |
{{ message }} | |
<div> | |
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DefaultController extends Controller | |
{ | |
\** | |
* @Route("/", name="homepage") | |
*\ | |
public function helloAction(Request $request) { | |
// Ajaxリクエストからの判定 | |
$request->isXmlHttpRequest; | |
// Getパラメータからの取得 | |
$request->query->get("hoge"); | |
// Postパラメータからの取得 | |
$request->request->get("hoge"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# hello.html.twig} | |
{% block body %} | |
<h1>Hi {{name}}!</h1> | |
{% endblock%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DefaultController extends Controller | |
{ | |
\** | |
* @Route("/", name="homepage") | |
*\ | |
public function indexAction() { | |
return $this->redirectToRoute("hello", ["name" => "test"]) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DefaultController extends Controller | |
{ | |
\** | |
* @Route("/hello/{name}", name="hello") | |
*\ | |
public function helloAction($name) { | |
return $this->render("index.html.twig",[ | |
'name' => $name | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment