O'Reilly logo

CouchDB and PHP Web Development Beginner's Guide by Tim Juravich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action : handling 404 errors with Bones

Let's create a view for 404 errors that we can use around our application.

  1. Start by creating a new view in our views/error/ directory called 404.php.
  2. Let's add some very basic code to 404.php that will inform the visitor that our application couldn't find the requested page.
    <div class="hero-unit">
    <h1>Page Not Found</h1>
    </div>
    
  3. In order for us to render this view, let's add another function called error404 into our lib/bones.php file. This function will nicely display 404 errors for us.
    public function error404() {
    $this->render('error/404');
    exit;
    }
    

What just happened?

We created a simple view, called 404.php, that we can show any time a 404 error occurs in our application. We then created a simple ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required