Oh Dear is the all-in-one monitoring tool for your entire website. We monitor uptime, SSL certificates, broken links, scheduled tasks and more. You'll get a notifications for us when something's wrong. All that paired with a developer friendly API and kick-ass documentation. O, and you'll also be able to create a public status page under a minute. Start monitoring using our free trial now.

Easy deployments for php projects

Link –

Let's talk a bit about deployments.

All the new projects I work on are hosted on servers that are provisioned by Forge. Forge has a quick deploy feature that allows you to pull the lastest master-commit onto the server, install composer dependencies, run migrations and so on.

It has two main drawbacks:

  • you can't see any output of the deployment script in your terminal
  • you can't do some stuff locally on your computer
To solve these points I'm switching from Forge's quick deploy feature to Deployer.
Deployer is a deployment tool written in PHP, it's simple and functional. Deploy your code to all servers you want, it supports deploy via copy, or via VCS (like git), or via rsync. Run your tasks on all your servers, or use our recipes of common tasks for Symfony, Laravel, Zend Framework and Yii.
You can install Deployer via composer. To use Deployer a deploy.php file must be added to your project. This file describes your deployment process. No worries, you can write it in php using a very clean and readable syntax. The documention on how to write the deploy.php-file is a bit vague at this point, but you'll get a good idea of how things work by taking a look at my deploy.php-file.

To run deployer you'll use this command:

[code lang="bash"] dep



I've made a bash alias that uses the name of the git branch you're currently on:

[code lang="bash"]
alias deploy='dep deploy $(git symbolic-ref --short HEAD)'

Now deploying a branch is as easy as just typing "deploy" when standing on a git repo in your terminal. This is a much nicer way to handle deployments. What I really like is that, now a deploy.php stored in the git repo, the deployment process is also versioned.

If you find Deployer doesn't meet your needs, Rocketeer, Phing and Capistrano are some more advanced alternatives. Envoy is nice too, but I haven't found a way to run stuff locally.

Stay up to date with all things Laravel, PHP, and JavaScript.

You can follow me on these platforms:

On all these platforms, regularly share programming tips, and what I myself have learned in ongoing projects.

Every month I send out a newsletter containing lots of interesting stuff for the modern PHP developer.

Expect quick tips & tricks, interesting tutorials, opinions and packages. Because I work with Laravel every day there is an emphasis on that framework.

Rest assured that I will only use your email address to send you the newsletter and will not use it for any other purposes.

Comments

What are your thoughts on "Easy deployments for php projects"?

Comments powered by Laravel Comments
Want to join the conversation? Log in or create an account to post a comment.