This version is outdated. You should upgrade your project to Mako 9.1 or Mako 10.0!


The response class is responsible for sending output to the browser.

An instance of the response object is always available in controllers and it can be accessed like this:



The body method can be used to override the response body in the after method of your controller.

public function after()
	// Will prefix the response with "Hello, world!";
	$this->response->body('Hello, world!' . $this->response);

The status method is a helper method that makes it easy to send HTTP status headers. The status method will always reply using the same protocol version as the request.

$this->response->status(404); // Sends the 404 "Not Found" header.

The type method lets you set the content type of your response. The default charset of the application is used if the second parameter is left empty.


The redirect method allows you to redirect a user to a different URL. The default status sent by the method is 302 Found but you can override this by setting the status code in the second parameter.

// Redirects to


// Redirects to with the "301 Moved Permanently" header

$this->response->redirect('', 301);

The filter method allows you to filter the output before sending it.

	return str_ireplace('[mako:assets]', Assets::location(), $body);