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(); $this->couch = new Sag('127.0.0.1', '5984'); $this->couch->setDatabase('verge'); }