/BlogController.php Secret
Last active
January 19, 2018 16:06
Symfony Controller Normal
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
<?php | |
namespace App\Controller; | |
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; | |
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\HttpFoundation\Response; | |
use Symfony\Component\Routing\Annotation\Route; | |
class BlogController extends AbstractController | |
{ | |
/** | |
* @Route("/", defaults={"page": "1", "_format"="html"}, name="blog_index") | |
* @Method("GET") | |
*/ | |
public function index(Request $request): Response | |
{ | |
// Code to show all the posts | |
} | |
/** | |
* @Route("/posts/{slug}", name="blog_post") | |
* @Method("GET") | |
*/ | |
public function postShow(Post $post): Response | |
{ | |
// Code to show a single post | |
} | |
/** | |
* @Route("/comment/{postSlug}/new", name="comment_new") | |
* @Method("POST") | |
*/ | |
public function commentNew(Request $request): Response | |
{ | |
// Code to add a comment | |
} | |
/** | |
* @Route("/search", name="blog_search") | |
* @Method("GET") | |
*/ | |
public function search(Request $request): Response | |
{ | |
// Code to search | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment