Last active
November 26, 2019 09:01
-
-
Save tkfm-yamaguchi/3bc11069f60e609091ea199f5456987b to your computer and use it in GitHub Desktop.
the simplest form of Symfony controller
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 AppBundle\Controller; | |
use Exception; | |
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; | |
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | |
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | |
use Symfony\Component\HttpFoundation\JsonResponse; | |
class MyController extends Controller | |
{ | |
/** | |
* @Route("/foobar", name="foobar") | |
* @Method("GET") | |
* | |
* @return JsonResponse | |
* @throws Exception | |
*/ | |
public function indexAction(): JsonResponse | |
{ | |
$em = $this->getDoctrine()->getManager(); | |
var_dump($em); | |
return new JsonResponse("{}"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment