# PHP Quick Start

This project shows you how to implement a simple
piece of Glassware that demos the major functionality of the Google Mirror API.

To see a fully-working demo of the quick start project, go to
[https://glass-python-starter-demo.appspot.com](https://glass-java-starter-demo.appspot.com).
Otherwise, read on to see how to deploy your own version.

[Download on GitHub](https://github.com/googleglass/mirror-quickstart-php)

## Prerequisites

- PHP 5.3.x or higher
- A web server - You need a place to host your files. [Apache httpd](http://httpd.apache.org/) and [nginx](http://nginx.org/) work great.
- To use subscriptions you also need an Internet accessible hosting environment with a valid SSL certificate signed by a trusted certificate authority.

> [!NOTE]
> **Note:** You can start developing with a localhost instance of your HTTP server, but you must have an Internet accessible host to use the subscription features of the API.

## Creating a Google APIs Console project

Next, enable access to the Google Mirror API:

1. Go to the [Google APIs console](https://code.google.com/apis/console/) and create a new API project.
2. Click **Services** and enable the Google Mirror API for your new project. ![the Google Mirror API on the Google API Console](https://developers.google.com/static/glass/images/api-console-enable-glass.png)
3. Click **API Access** and create an OAuth 2.0 client ID for a web application. ![the API Access section of the Google API console](https://developers.google.com/static/glass/images/api-console-client-id.png)
4. Specify the product name and icon for your Glassware. These fields appear on the OAuth grant screen presented to your users. ![specifying brand information](https://developers.google.com/static/glass/images/api-console-client-id-brand-info.png)
5. Select **Web application** and specify any value for the hostname, such as `localhost` ![selecting application type](https://developers.google.com/static/glass/images/api-console-client-id-app-type.png)
6. Click **Edit settings...** for the client ID to specify redirect URIs. Specify the callback URLs for your local development web server, for example `http://localhost:8080/oauth2callback`, and for your deployed web server, for example `https://example.com/oauth2callback`. ![the Google API console configuration panel for redirect URIs](https://developers.google.com/static/glass/images/api-console-redirect-uris.png)
7. Make note of the client ID and secret from the Google APIs Console. You'll need it to configure the quick start project. ![the client id and secret on the Google API console](https://developers.google.com/static/glass/images/api-console-client-id-and-secret.png)

> [!NOTE]
> **Note:** You also need the simple API key for the PHP starter project.

## Configuring the project

Enter your client ID, secret, simple API key, a base URL and a location where a
SQLite database can be created in `config.php`:

    $api_client_id = "1234.apps.googleusercontent.com";
    $api_client_secret = "ITS_A_SECRET_TO_EVERYBODY";
    $api_simple_key = "AIzaSyCCbHcqDeb0oycQ9niV8P3n0F0qM";

    $base_url = "http://example.com/starter-project";

    $sqlite_database = "/tmp/database.sqlite";

## Deploying the project

Deploy the Quick Start project to your host server:

1. Copy the PHP Quick Start directory to the documents directory of your HTTP web server.
2. Depending on your system configuration, you may need to pre-create a writable
   file for the SQLite database:

       $ touch /tmp/database.sqlite
       $ chmod 777 /tmp/database.sqlite