I want to throw a '404 Page not found' error from my controller. How can I do that?
I use Zend Framework 2 not 1.
class IndexController extends AbstractActionController
{
public function previewAction ()
{
return $this->notFoundAction ();
}
}
Just try with:
$this->getResponse()->setStatusCode(404);
return;
in your controller's action method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With