Skip to content

Instantly share code, notes, and snippets.

@freekmurze
Last active February 5, 2021 02:43
Show Gist options
  • Star 26 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save freekmurze/8234a542d94b1ec54e5b to your computer and use it in GitHub Desktop.
Save freekmurze/8234a542d94b1ec54e5b to your computer and use it in GitHub Desktop.
A sample deploy.php file that can be used with Deployer (http://deployer.in)
<?php
/*
* Define the servers
*/
server('production-web', '<your server url>')
->path('<path to the project on your server>')
->user('<user on the server>')
->pubKey();
/*
* Define the states
*/
stage('master', ['production-web'], ['branch' => 'master']);
/*
* Make sure we are on the right branch
*/
task('deploy:checkout', function () {
runLocally('git checkout '.get('branch', '').' 2> /dev/null');
})->desc('checking out git branch');
/*
* Bring the app on the server down
*/
task('deploy:app_down', function () {
run('php artisan down');
run('php artisan cache:clear');
})->desc('bringing app down');
/*
* Pull the changes onto the server
*/
task('deploy:pull_changes', function () {
run('git pull origin '.get('branch', '').' 2> /dev/null');
run('php artisan cache:clear');
})->desc('pull changes on server');
/*
* Locally generate assets and transfer them to the server
*/
task('deploy:generate_assets', function () {
runLocally('gulp compile');
run('rm -rf public/assets/*');
upload('public/assets/', 'public/assets/');
})->desc('generating assets');
/*
* Run composer install on the server
*/
task('deploy:composer_install', function () {
run('composer install');
})->desc('running composer install');
/*
* Run the migrations on the server
*/
task('deploy:run_migrations', function () {
run('php artisan db:backup');
run('php artisan migrate --force --env=production');
})->desc('running migrations');
/*
* Bring the app back up
*/
task('deploy:app_up', function () {
run('php artisan cache:clear');
run('php artisan up');
})->desc('bringing app up');
/*
* Run all the tasks in the right order
*/
task('deploy',
[
'deploy:checkout',
'deploy:app_down',
'deploy:pull_changes',
'deploy:generate_assets',
'deploy:composer_install',
'deploy:run_migrations',
'deploy:app_up',
]
);
@azazqadir
Copy link

I prefer using just github to deploy my PHP based apps on server. Using tools make things even more complicated. This simple method to deploy php application is quick. It also makes your workflow faster.

@JREAM
Copy link

JREAM commented Nov 1, 2018

But.............. I dont want to use Cloudways or another service to DEPLOY.... Especially with CloudWays RIP OFF pricing for SUCKERS 💃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment