Deploying Laravel to Coolify the Easy Way
Laravel package for Coolify deployments - dashboard, CLI tools, and smart Nixpacks generation that detects your stack automatically.
Deploying Laravel to Coolify the Easy Way
Coolify is great for self-hosting Laravel apps. But every time I deployed a new one, I was writing the same Nixpacks config, setting up the same supervisor processes, configuring the same environment variables.
Built a package to handle it: laravel-coolify.
What It Does
Dashboard, CLI tools, and smart Nixpacks generation for Laravel on Coolify. One command to provision a complete app with PostgreSQL and Redis. Another to deploy with real-time streaming logs.
php artisan coolify:provision
php artisan coolify:deploy --wait
Done. Your app is live.
The Dashboard
Visit /coolify in your app and you get a web interface for:
- Triggering deployments
- Viewing logs (application, build, deployment)
- Managing environment variables
- Checking database status
- Restarting services
- Rolling back failed deploys
It's just talking to Coolify's API, but having it integrated into your app is convenient.
The CLI Tools
Everything the dashboard does is also available as Artisan commands:
# Check deployment status
php artisan coolify:status
# View real-time logs
php artisan coolify:logs
# Restart the application
php artisan coolify:restart
# Rollback to previous deployment
php artisan coolify:rollback
Logs stream in real-time. Deployments show progress as they happen. No need to open the Coolify dashboard for quick operations.
The Smart Nixpacks Generation
This is the clever bit. The package scans your Laravel project and generates a production-ready nixpacks.toml.
If you've got Horizon installed, it adds a Supervisor process for Horizon. Same for Reverb, the scheduler, queue workers. It detects your packages and configures them automatically.
# Auto-generated based on your installed packages
[phases.setup]
nixPkgs = ["php83", "php83Extensions.redis", "python311Packages.supervisor"]
[start]
cmd = "supervisord -c /app/supervisord.conf"
No more copying Nixpacks configs between projects and forgetting to add the Horizon process.
One-Command Provisioning
Starting a new project? This creates everything on Coolify:
php artisan coolify:provision
It sets up:
- Your application (from your connected repo)
- A PostgreSQL database
- A Redis instance
- All the network connections between them
- Environment variables pointing to the right places
Then deploys immediately. New project to production in one command.
Setup
composer require stumason/laravel-coolify
php artisan coolify:install
Add to your .env:
COOLIFY_URL=https://your-coolify-instance.com
COOLIFY_TOKEN=your-api-token
Get the token from your Coolify settings. The package handles the rest.
Why This Exists
I got tired of the manual dance:
- Create app in Coolify
- Create database in Coolify
- Copy connection string to env vars
- Create Redis in Coolify
- Copy Redis connection to env vars
- Write Nixpacks config
- Remember to add supervisor for Horizon
- Deploy and hope nothing's missing
Now it's just coolify:provision. The package knows what Laravel needs.
The repo: github.com/StuMason/laravel-coolify
Get the Friday email
What I shipped this week, what I learned, one useful thing.
No spam. Unsubscribe anytime. Privacy policy.