Cakephp 404 Exception

[Solved] Cakephp 404 Exception | Php Frameworks Cakephp - Code Explorer | yomemimo.com
Question : cakephp 404 exception

Answered by : stormy-sloth-kpt3du0djzg1

use Cake\Http\Exception\NotFoundException;
public function view($id = null)
{ $article = $this->Articles->findById($id)->first(); if (empty($article)) { throw new NotFoundException(__('Article not found')); } $this->set('article', $article); $this->viewBuilder()->setOption('serialize', ['article']);
}

Source : https://book.cakephp.org/4/en/development/errors.html | Last Update : Fri, 31 Dec 21

Answers related to cakephp 404 exception

Code Explorer Popular Question For Php Frameworks Cakephp