Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A simple example Drupal Controller with an uncached JsonResponse
<?php
namespace Drupal\example\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
class ExampleController extends ControllerBase {
public function getJson(Request $request) {
$data = [];
// Do some useful stuff to build an array of data.
return new JsonResponse($data);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment