##How to install this thing

The following instructions are for Unixy machines. If you are on Windows, you're on your own. This document assumes you already have Apache, PHP 5.3.0+, and an IDE. What you will need:

* Redis, a key-value database
* Composer, a dead-simple package manager
* A Github account
* A Github SSH key
* RVM, Ruby Version Manager (optional)
* Fearless determination to conquer the unknown

###0. LAMP

You have all that, right? If not, get it. When you are done, you need two things: to add as much memory as you can to PHP (1GB is good). And to install the [Redis extension for PHP](https://github.com/nicolasff/phpredis).

You can either build the extension from source, or use PECL. Usually this works:

```
$ sudo pecl install redis
```

###1. Install Redis

On Unixy machines, installing Redis should be a cinch.  Please see [redis installation instructions](http://redis.io/download). Be sure to put the `redis-server` and `redis-cli` binaries in your bin folder.

###2. Get Redis up an running

How you run Redis in development is up to you. We would recommend running redis with persistence, and to run one instance of Redis for Brine and one instance for the cache at ports 6380 and 6381, respectively. A typical Redis config file looks like this:

```
dbfilename redis-import-6381.rdb
daemonize yes
port 6381
timeout 0
tcp-keepalive 0
loglevel debug
logfile stdout-import
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dir ./
```

Please see the helpful [Redis documentation page](http://redis.io/topics/config) for information on what all this means.

Once you have a config file ready, you're ready to get your Redis on. From the command line:

```
$ redis-server path/to/config
```

Note: The directory in which you run this command is the directory in which redis will store the

###3. Install Composer

Composer is also easy to install. Please visit [the composer docs for info](http://getcomposer.org/download/)

###4. Get your Github ssh key

You've probably already done this, but if not, then go give a look to the [Github help doc for SSH keys](https://help.github.com/articles/generating-ssh-keys). You'll need it for the Orchard-specific repos composer tries to fetch. We'll wait.

###5. Get Github Oauth Creds

Log into Github and visit the [application creation page](https://github.com/settings/applications/new). The homepage url should be you dev domain (http://mydevdomain.com) and the authorization callback URL is the same suffixed by '/auth' (http://mydevdomain.com/auth). Save that sucker and note your keys.

###6. Clone this here repo

```
$ git clone git@github.com:theorchard/redis-api.git
```

###7. Composer install

Rrom the redis-api root:

```
composer install
```

You should see something like:

```bash
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
  - Installing brine/brine (dev-master c9c8d43)
    Cloning c9c8d43fbf7e03149f7e83715b0cc39c4450b1e5

  - Installing symfony/event-dispatcher (v2.3.6)
    Downloading: 100%

  - Installing guzzle/guzzle (dev-hotfix/response-xml-visitor-internals 207efd1)
    Cloning 207efd1792256339bfc208165556d6943f0eee58

  - Installing symfony/routing (v2.3.6)
    Downloading: 100%

  - Installing symfony/http-foundation (v2.3.6)
    Downloading: 100%

...

```

###8. Configure

In `/config` directory rename `config_shadow.json` to  `config.json`. The settings are:

* `auth` Put your Github auth creds from step 5 here.
* `hotplate` See the specific hotplate doc for this one. The hotplate warms the cache. Unless you are working on developing for the hotplate, this optional.
* `cache` If you have an instance of redis for caching, put the values here:
    * `redis` your development redis host and port
    * `clear_host` if you are working on developing to clear the cache, put the host value here. For more on cache hosts see [here](https://github.com/theorchard/redis-lib/blob/master/usage.md).
    * `queue` this is the amazon sqs queue that will handle messages meant for queue deletion. For development purposes, you can use your own arbitrariy queue.
* `mysql` If you are hitting DW for data, put your DW MySQL creds here. Used only for ETL functionality, so you probably won't need this.
* `debug` This should be `false` in production. If true, JS will be served minified and concatenated.
* `default_template` This should never have been put here. Ignore it. We are finding those responsible for these errors. They will pay.
* `brine` If you are using brine data store enter your Redis info here. Environment variables should be self explanatory.
* `mail` If you want to receive emails from the Brine pipeline, enter the noreply creds (`from`) and your cred `to` here.
* `aws` Your aws creds. Used for cache clearance.
* `loggly` Your loggly creds. Again used for cache clearance.

###9. Logs & import

Chmod the `logs` directory to 755 (or 777, if you are feeling like living on the edge). Also make an `import` directory and do the same.

```
$ chmod 755 logs && mkdir import && chmod 755 import
```

###10. Web Server

The public directory for this app is `/web`.

###11. Contemplate the power of ENTERPRISE

<pre>
                 _________
                / _______ \
               / /       \ \
              / /         \ \
             | |           | |
             | |           | |
              \ \         / /        ___,
        _______\ \_______/ /______,-'   |
     ,-'____________   ___________      |
   ,',-'            | |           '-,___|
 ,','               | |                 '
 || .,-,.           | |
 \\_'- //           | |
  `-==='            | |
               _____| |_____
              |_____   _____|
                    | |
                    | |
               ___  | |  ___
               \  \ | | /  /
                \  \| |/  /
                 \       /
                  \     /
                   \   /
                    \_/
</pre>