22

I'm starting to use Laravel 4 seriously in my projects. I understand that this framework offers many advantages when developing RESTful applications. But I understand that there is no consensus about how do deployment / publishing and app using Laravel. I am still using FTP to transfer files to my Production host. But my question is, Is there any standard way to do the same but from Laravel? I am faithful believing that with a little ingenuity one can create something like php artisan publish [Production server name and SSH credentials] as parameters.

I have read something interesting from Anahkiasen/rocketeer and Christopher Pitt, both great sources but there is a consensus or standard way to publish applications using laravel?

m02ph3u5
  • 3,022
  • 7
  • 38
  • 51
James
  • 587
  • 1
  • 7
  • 21
  • Capistrano is Awesome! Give it a try. – Goldentoa11 Dec 04 '13 at 19:24
  • why not write a bash (or Powershell) script to pull your files out of git/svn and install on the Production server? – msturdy Dec 04 '13 at 19:40
  • My consern is that Capistrano is more for Ruby apps. Its possible to use it for Laravel? – James Dec 04 '13 at 19:42
  • You can create your own custom commands for artisan.. have you seen this? http://laravel.com/docs/commands – msturdy Dec 04 '13 at 19:51
  • 1
    Yes, that is the reason to believe that **php artisan publish [Production server name and SSH credentials]** is totally doable. Right now I'm exploring that option. – James Dec 04 '13 at 20:01

5 Answers5

20

This is not really a Laravel problem/question, you have to ask on a dev-ops forum what they would do to deploy a PHP application like yours.

Your Laravel application is basically PHP application, some packages are provided by Composer, so it's more a Composer application than a Laravel one, but you might have some Laravel needs, like executing php artisan migrate, or any other artisan command to post-deploy your application, or not, so, it's more a requirement of your application than Laravel, right?

I developed a package to do my deployments, Deeployer. The intent of this package is, everytime I push my application to the production (or staging) branch, Github will fire a hook that tells my server to do whatever it needs to deploy my application to my own VPS. In a basic deployment it will:

1) git pull the repository

2) Execute composer update to update my vendor folder

3) Execute bower update to download whatever js or css I've installed

4) Execute php artisan migrate to upgrade my database schema

5) Execute chmod and chown to fix whatever permission mess those commands might have made to my directories while downloading files

See? Those are things that are very particular to my deployment structure, that's why I don't really think you are going to find consensus about a deployment app. When Anahkiasen first build Rocketeer, someone shout: "Why are you doing this if we already have Capistrano?".

Yesterday I bumped into this one: http://www.deployhq.com/packages, used by Ben Corlet from Cartalyst and other nice guys.

There's also Rocketeer: http://rocketeer.autopergamene.eu/.

Don't forget that Laravel itself has it's own SSH Remote component (I used it on Deeployer and Rocketeer uses it too), that might help you do whatever you need to deploy your app.

So, you better think what are your deployment needs and find your way, using a package, app or just Laravel.

Antonio Carlos Ribeiro
  • 86,191
  • 22
  • 213
  • 204
  • Excellent information. Really answer my doubts for which the question originates. Thanks for the clarity of your answer.With all the information I have enough to work. Once again, thanks! – James Feb 03 '14 at 18:13
  • GIT support auto deploy extremely easy. Ex. `git push origin deploy` => deployed. Refer to: http://www.sitepoint.com/deploy-website-using-laravel-git/ – Jonny Vu Feb 01 '16 at 03:34
  • 1
    I wouldn't recommend running `composer update` in production, as it will install the latest available version of each package that satisfies the version constraints in `composer.json`. Those will often be different from the versions you have installed in development & testing. Instead, you want to `composer install` the exact versions that are specified in `composer.lock` which is tracked in your vcs and against which you're running the tests. – jsphpl Aug 10 '18 at 16:11
6

There are a lot of deployment tool, like Capistrano. I recommend you to take a look at Deployer: it's has simple api, bundled with recipes for popular frameworks and apps, and can do 100% parallel task execution. Also it requires only for PHP.

Here is an example of simple task:

task('my_task', function () {
    // Your tasks code...
});

Also it has a good quality code:

Code Quality Code Climate Code Coverage

Deployer

Xander Luciano
  • 3,753
  • 7
  • 32
  • 53
Anton Medvedev
  • 3,393
  • 3
  • 28
  • 40
  • 1
    2 years later but I tried deployer out today and got a full setup up and running perfectly in just a few hours. Easy to use and simple API for sure. – Xander Luciano Mar 10 '18 at 04:02
2

You may want to check out Rocketeer: http://rocketeer.autopergamene.eu/

fl3x7
  • 3,723
  • 6
  • 26
  • 37
0

If you are asking for a standard, I don't think there is one. But an alternative from FTP, well, have you considered using git as a way to deploy your site to production?

Here is how you do it: http://danbarber.me/using-git-for-deployment/ (Link is broken) https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps

Basically the summary is that you have a bare git repository, your own local repository and your production repository.. now by configuring the correct hooks, when you push to the bare git repository, a hook in it will tell the production repository to pull the most recent changes you commited down to the production. And in addition, setting up the correct credentials in your config depending on the environment.. you can create a new folder ex. app/config/production and app/config/stage so that you can easily run the application even while switching on both servers..

reikyoushin
  • 1,993
  • 2
  • 24
  • 40
-1

I'm not so sure about a standard way either. You do have Forge and Envoyer that work with Laravel, so that is something to look into.

Here is a way to deploy Laravel using Rocketeer and Git. It is very easy to setup and allows you to use multiple servers (think staging, production, etc.)

http://dericcain.com/blog/deploying-laravel-5-with-rocketeer

dericcain
  • 2,182
  • 7
  • 30
  • 52