A powerful zero-downtime deployment tool for Laravel applications built with Laravel Zero. Deploy your Laravel applications from GitHub releases with confidence using an easy-to-use CLI tool.
- π Zero Downtime Deployment - Symlink-based deployments ensure your application stays online
- π¦ GitHub Releases Integration - Automatically fetch and deploy from GitHub releases
- π Automatic Rollback - Rolls back to previous version if deployment fails
- ποΈ Release Management - Keep multiple releases and easily cleanup old ones
- π Preserve Important Files - Automatically preserves
.env, storage, and other critical files - β‘ Laravel Optimization - Runs cache optimization commands automatically
- π Health Checks - Verifies deployment success before finalizing
- π¨ Beautiful CLI - Clean, colored output with progress indicators
- βοΈ Highly Configurable - Configure via
.env, config file, or command options
composer global require 4msar/laravel-deployerDownload the latest laravel-deployer PHAR file from the releases page:
wget https://github.com/4msar/laravel-deployer/raw/main/builds/laravel-deployer -O laravel-deployer
chmod +x laravel-deployer
sudo mv laravel-deployer /usr/local/bin/laravel-deployercurl -sS https://raw.githubusercontent.com/4msar/laravel-deployer/main/install.sh | bashgit clone https://github.com/4msar/laravel-deployer.git
cd laravel-deployer
composer install
php laravel-deployer app:buildCopy the example configuration:
cp .env.example .envEdit .env with your settings:
DEPLOY_GITHUB_REPO=your-username/your-repo
DEPLOY_APP_NAME=your-app
DEPLOY_INSTALL_DIR=/var/www
DEPLOY_WEB_USER=www-data
DEPLOY_GITHUB_TOKEN=your-github-token
DEPLOY_KEEP_RELEASES=2You can override configuration using command-line options:
laravel-deployer deploy \
--repo=your-username/your-repo \
--app-name=your-app \
--install-dir=/var/www \
--web-user=www-data \
--keep-releases=2# Interactive mode (prompts for configuration)
laravel-deployer deploy
# With options
laravel-deployer deploy --repo=username/repo --install-dir=/var/www# Force deployment even if same version
laravel-deployer deploy --force
# Skip database migrations
laravel-deployer deploy --skip-migrations
# Auto cleanup old releases without prompting
laravel-deployer deploy --auto-cleanup
# Use GitHub token for private repos
laravel-deployer deploy --github-token=your_token_here
# Keep specific number of old releases
laravel-deployer deploy --keep-releases=5laravel-deployer deploy \
--repo=4msar/bill-organizer \
--app-name=bill-organizer \
--install-dir=/var/www \
--web-user=www-data \
--github-token=ghp_xxxxxxxxxxxx \
--keep-releases=3 \
--auto-cleanup- Fetch Release: Downloads the latest release from GitHub
- Prepare: Extracts the release to a temporary directory
- Preserve Files: Copies important files from current installation (
.env, storage, etc.) - Deploy: Creates a new release directory and copies files
- Optimize: Runs Laravel optimization commands (config, route, view cache)
- Migrate: Optionally runs database migrations
- Switch: Updates symlink to point to new release
- Health Check: Verifies the application is working
- Cleanup: Removes old releases (optional)
- Rollback: Automatically rolls back on failure
After deployment, your directory structure will look like:
/var/www/
βββ your-app -> your-app-v1.2.0 (symlink to current release)
βββ your-app-v1.2.0/ (current release)
βββ your-app-v1.1.0/ (previous release)
βββ backups/ (backup directory)
- PHP ^8.4
- Composer
- Git
curl,unzipcommand-line tools- Proper file permissions on target server
For private repositories or to avoid rate limiting, create a GitHub Personal Access Token:
- Go to https://github.com/settings/tokens
- Click "Generate new token (classic)"
- Select scopes:
repo(for private repos) orpublic_repo(for public repos) - Copy the token and use it with
--github-tokenoption or in.env
- Test Locally: Always test your release locally before deploying
- Backup Database: Backup your database before running migrations
- Use Releases: Tag your code with semantic versioning (v1.0.0, v1.1.0, etc.)
- Preserve Files: Ensure all important files are listed in config
- Health Checks: Verify your application after deployment
- Keep Releases: Keep at least 2 previous releases for quick rollback
Run with sudo or ensure your user has write permissions:
sudo laravel-deployer deployUse a GitHub token to increase rate limits:
laravel-deployer deploy --github-token=your_tokenSkip migrations and run them manually:
laravel-deployer deploy --skip-migrations
cd /var/www/your-app
php artisan migrateIf automatic rollback fails:
cd /var/www
ln -sfn your-app-v1.1.0 your-appTo update laravel-deployer to the latest version, run:
laravel-deployer self-updateIt will download and replace the current PHAR with the latest release.
This project is open-sourced software licensed under the MIT license.
Built with Laravel Zero - The PHP framework for console applications.