blog

  • Home
  • blog
  • Easy Deployment of PHP Applications with Deployer

Easy Deployment of PHP Applications with Deployer

Everybody tries to automate their development process, testing, code formatting, system checks, etc. This is also the case for deploying our applications or pushing a new version to the production server. Some of us do this manually by uploading the code using an FTP client, others prefer Phing, and Laravel users will prefer Envoyer for this process. In this article, I’m going to introduce you to Deployer – a deployment tool for PHP.

Deployer LOGO

Demo Application

I will be using an application from a previous article for the demo. The application will be deployed to a DigitalOcean droplet. To follow along, you can clone the demo application’s source code from GitHub.

Installation

Deployer is packaged as a PHAR file that we can download to our local machine. We can also move it to the user’s bin directory to make it global. Check the documentation for more details.

mv deployer.phar /usr/local/bin/dep
chmod +x /usr/local/bin/dep

Defining Servers

After cloning the demo repository, we need to create a new file called deploy.php where we’ll define our deployment steps.

The first step is to define our deployment servers. We can authenticate normally using a username and a password.

// deploy.php

server('digitalocean', '104.131.27.106')
    ->user($_ENV['staging_server_user'])
    ->password($_ENV['staging_server_password']);

We can also define the type of this server (staging, production, etc), which allows us to run tasks (more on tasks later) on a specific server stage.

Continue reading %Easy Deployment of PHP Applications with Deployer%

LEAVE A REPLY