PHP Deployer is a great little utility for deploying your PHP app via command line. It doesn’t force you to use any specific tech stack and simplifies the process of getting your app live.

Prerequisites

This blog post assumes the following:

  • You have an app or website written in PHP, be it a popular framework or just plain ol’ PHP
  • You are familiar with command line, SSH and are looking for a deployment method
  • You have SSH access to the server where your site/app will be hosted
  • Your website is not mission critical (there might be errors :wink:)

I have a Lumen app which I will be deploying with Deployer in this blog post, so there might be Lumen/Laravel specific commands and roles.

Install

There are a couple of ways you can  install deployer. To keep my code device & environment agnostic, I have opted for the  composer method.

This means I don’t have to set up deployer on the machine if I wish to deploy my app, just SSH access and composer.

The composer version of deployer is run with php vendor/bin/dep, however for the rest of this tutorial I will reference the global command dep.

Deployment and finishing

This may seem like an odd step to put here, but seeing the finished result will help you understand the configuration.

Once deployed (the example below has a couple of deployments), a PHP Deployer app has the following folder & file structure in the deploy_path location:

  • current -> releases/2
  • .dep/
  • releases/
  • 1/
  • … your application code
  • .env -> …/…/shared/.env
  • 2/
  • … your application code
  • .env -> …/…/shared/.env
  • shared/
  • .env
  • storage/

(I hope that makes sense).

#php

Automatic Deploying Your Lumen App with PHP Deployer So You Don't Have to Manually Do It.
1.45 GEEK