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 — using constants to get the location of the working directory

The first thing that we need to do is create a named constant called ROOT, which will give us the full location of our working directory. Until now, we haven't had to do any extra including of files, but with our layouts and views, it'll start to get a bit difficult if we don't add some functionality to get the working directory. In order to support this, let's add a simple line of code right at the top of our lib/bones.php file.

<?php
ini_set('display_errors','On');
error_reporting(E_ERROR | E_PARSE);
define('ROOT', __DIR__ . '/..');

function get($route, $callback) {
...
}

What just happened?

This line of code creates a constant named ROOT that we can then use throughout ...

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