Skip to content

Instantly share code, notes, and snippets.

@tkfm-yamaguchi
Last active November 26, 2019 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkfm-yamaguchi/3bc11069f60e609091ea199f5456987b to your computer and use it in GitHub Desktop.
Save tkfm-yamaguchi/3bc11069f60e609091ea199f5456987b to your computer and use it in GitHub Desktop.
the simplest form of Symfony controller
<?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