Skip to content

Proposal how to fix TODO #5

@Toflar

Description

@Toflar

I'm don't know why exactly you have to stop script execution here:

header('Content-Type: application/json');

But I assume there are technical reasons for it. I've encountered the same in the past and I've solved it by throwing a custom exception which you can then catch in the controller.
Not aborting the script execution has a few advantages:

  • You don't miss setting the Content-Length header like it is now ;-)
  • You can continue the script execution flow which means events etc. can still be fired after that before e.g. the response is sent to the client
  • Debugging scripts can continue to work
  • etc.

Just as an idea ;-) Over at Contao we even built a ResponseException which takes a Symfony HttpFoundation Response as argument so you can send a proper response from within legacy code :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions