In Joomla 3.x versions I use JResponse to get and set the body.

function onAfterRender() {
          $content = JResponse::getBody();

But in Joomla4 it returns Class 'JResponse' not found. So how to get the body in Joomla4?



According to the documentation, JApplicationWeb seems to be alive and well in Joomla4.

since 2.5.0

note As of 4.0 this class will be abstract

  • The getters:



  • The setters:




Relevant references and examples:

  • 1
    JFactory::getApplication()->getBody() is definitely recommended way. – George Wilson Oct 25 '19 at 15:40
  • Tell me more. Better yet, tell everyone in an answer please. You know better than me. Why is one better than the other? @George – mickmackusa Oct 25 '19 at 15:43
  • JFactory::getApplication returns an instance of JApplicationCms which is a subclass of JApplicationWeb. As a result rather than calling a non-static method in JApplicationWeb statically - grab the main application object and call the function in it's non-static intended way :) – George Wilson Mar 20 '20 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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