I have been creating a table from mysql result , but its printing the html markup only and says controller must return a response . what may be the reason ?

LogicException: The controller must return a response (

(5 rows)group_nameparent_nameEditDeleteSelect itemsL2V9http://>edithttp://>delete

given). in Symfony\Component\HttpKernel\HttpKernel->handleRaw() (line 157 of vendor/symfony/http-kernel/HttpKernel.php).

1 Answer 1


The error message is not pointing in the right direction. It should say:

"The controller must return a render array"

For example the most basic one:

return [
  '#markup' => '<p>This is html markup</p>',

Usually the render array is more complex, for example to build a table, see https://www.codimth.com/blog/web/drupal/render-table-drupal-8

The error message is raised by Symfony, and from the stand point of Symfony this is correct. A controller must provide a response, but Drupal has extended the response handling to look for render arrays, that are then used to generate a response with the rendered html. If you don't provide a render array, then there is no response and then this error message will come up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.