Response
A response is an output produced by MVC controller.
To output from a controller, you have either to return a string or \Ip\Response object. There are following extended types:
- \Ip\Response\Json
- \Ip\Response\Layout
- \Ip\Response\PageNotFound
- \Ip\Response\Redirect
You can implement your own reponse types by extending \Ip\Response class.
A controller should never echo output by itself.
Output a string
return 'Hello world';
Output in JSON format
Mostly used for AJAX interactions
return new \Ip\Response\Json( array('exampleMessage' => 'Hello world'));
Display 404 Page not found message
This will display error 404 page with correct headers.
return new \Ip\Response\PageNotFound();
Redirect a browser to some other page
return new \Ip\Response\Redirect('http://www.example.com');