Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

azazqadir commented Sep 18, 2018

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

This comment has been minimized.

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
You can’t perform that action at this time.