Skip to content

Instantly share code, notes, and snippets.

@ahmadawais
Last active July 18, 2018 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmadawais/40f875b2d8118e4637f7a0723b567599 to your computer and use it in GitHub Desktop.
Save ahmadawais/40f875b2d8118e4637f7a0723b567599 to your computer and use it in GitHub Desktop.
Composer Deploy on Server

Composer Deploy

You can use different vendor folders on dev and prod servers.

// Autoloader for localhost and production.
if ( file_exists( dirname( __FILE__ ) . '/vendor/autoload.php' ) ) {
	require_once dirname( __FILE__ ) . '/vendor/autoload.php';
} else {
	require_once dirname( __FILE__ ) . '/../../private/composer/vendor/autoload.php';
}
{
"name": "namespace/project",
"description": "Some description.",
"license": "proprietary",
"config": {
"sort-packages": true,
"optimize-autoloader": true
},
"autoload": {
"psr-4": {
"CPA\\": "class"
}
},
"require": {
"ahmadawais/sendy-php-api": "^2.3",
"drewm/mailchimp-api": "^2.5",
"rmccue/requests": "^1.7"
}
}
#! /usr/bin/env bash
# Refresh the project.
function refresh() {
cd ~/public/cpapi
git fetch --all
git reset --hard origin/master
/usr/local/bin/composer config vendor-dir ~/private/composer/vendor && /usr/local/bin/composer install --no-ansi --no-dev --no-interaction --no-progress --no-scripts --optimize-autoloader
}
# Repeating every 10 to 15 seconds.
REPEAT=5
DELAY=10
COUNT=0
while (( COUNT++ < REPEAT )); do
echo " ———————————— RUN # $COUNT ———————————— "
sleep $DELAY
refresh
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment