Published 21st May 2014
php artisan down composer update php artisan migrate php artisan up
This means logging on to the remote server, finding the right direcotry and manually running each of these commands. After a while this get’s a bit tiresome and could become a big issue if you forget to do it. So I came up with a custom Laravel command that can be run after a deploy.
Put the above code in app/commands/PostDeploy.php (although it can go anywhere) and then register the command by adding the following line to app/start/artisan.php:
This reduces the above four commands (and any others you might want to add) into a single command:
php artisan post-deploy
It even supports passing an environment to the migrate command:
php artisan post-deploy --env=production
The best part is that I can get Beanstalk to trigger this command automatically after a deploy so that I don’t even need to do anything (excpet maybe check that the deployment ran ok). Awesome sauce.