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 — adding Sag to Bones

Enabling and setting up Sag to work with Bones is extremely easy. Let's walk through it together!

  1. Open lib/bones.php inside of our working directory, and add the following line to the top of our class:
    <?php
    define('ROOT', __DIR__ . '/..');
    require_once ROOT . '/lib/sag/src/Sag.php';
    
    
  2. We need to make sure that Sag is ready and available on each request. Let's do this by adding a new variable to Bones called $couch, and setting it in our __construct function:
    public $route_segments = array();
    public $route_variables = array();
    public $couch;
    
    public function __construct() {
    $this->route = $this->get_route();
    $this->route_segments = explode('/', trim($this->route, '/'));
    $this->method = $this->get_method();
    

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