Introduction

This tutorial will show you how to deploy your PHP app in several minutes. These instructions will also give you enough information to make the most out of Dokkur.

Be sure that you already have:

  1. Dokkur account.
  2. SSH keys added to your account.
  3. PHP installed locally
  4. Composer installed locally.

Set up

In this step you will install the Dokkur Toolbelt that gives you you access to the Dokkur Command Line Interface (CLI).

After installation you can use dokkur login command to log in with your email and password you set when creating Dokkur account.

Prepare the app

To deploy an app you need to have the app prepared for deployment.

If you don’t have your own PHP project, you can use a template that we have already prepared for you:

$ git clone https://github.com/dokkur/php-getting-started.git
$ cd php-getting-started

You now have a functioning git repository that contains a simple application as well as a composer.json file. Make sure you’ve installed Composer. Dokkur uses Composer for dependency management in PHP projects.

If you have a PHP app that you want to deploy, you need to do some preparations.

Declare app dependencies

How does Dokkur recognize an app as a PHP app? The answer is by the existence of a composer.json file in the root directory.

It may look something like this:

{
"require" : {
"silex/silex": "~1.3",
"monolog/monolog": "~1.7",
"twig/twig": "^1.19",
"symfony/twig-bridge": "^2.7"
},
"require-dev": {
"heroku/heroku-buildpack-php": "*"
}
}

The composer.json file specifies dependencies that should be installed with your application. When an app is deployed, Dokkur reads this file and installs the appropriate dependencies into the vendor directory.

Your PHP app can then make use of the dependencies after a simple require:

require('../vendor/autoload.php');

Run the following command to install the dependencies, preparing your system for running the app locally:

$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing psr/log (1.0.0)
Loading from cache
...
Writing lock file
Generating autoload files

You should always check composer.json and composer.lock into your git repo. The vendor directory should be included in your .gitignore file.

Create a new app

Follow these steps:

  1. Open website, go to Personal apps (left menu bar)
  2. Click ⨁ button to open New App interface
  3. Enter the app’s name (Caution! Use latin lowercase and numbers, e.g. myapp007), choose available and convenient instances for hosting, pick Custom App template and press Create App button.

Congrats! Your app has easily been created. Now you need to deploy it. Just do it!

Add BUILDPACK_URL config var

  1. Go to Settings page, in Environmental variables section click on Edit button.
  2. Choose ADD NEW VARIABLE
  3. In the Name field write BUILDPACK_URL
  4. In the VALUE field put
    https://github.com/dokkur/buildpack-php
  5. Save settings

Deploy your app

  1. Go to Settings page, copy the app git url from the Git URL section.
  2. Switch to Dokkur Toolbelt and execute this command:

    git remote add dokkur git_url
    Instead of git_url paste your app's git url.

  3. Push your app:
    git push dokkur master
    If you want to deploy another branch, run:
    git push dokkur yourbranch:master

Hell yeah! Your app is deployed! Open yourappname.dokkurapp.com in your browser.