How to Deploy a Laravel Project
require 'recipe/laravel.php';
Deployer is a free and open source deployment tool written in PHP. It helps you to deploy your Laravel application to a server. It is very easy to use and has a lot of features.
Three main features of Deployer are:
- Provisioning - provision your server for you.
- Zero downtime deployment - deploy your application without a downtime.
- Rollbacks - rollback your application to a previous version, if something goes wrong.
Additionally, Deployer has a lot of other features, like:
- Easy to use - Deployer is very easy to use. It has a simple and intuitive syntax.
- Fast - Deployer is very fast. It uses parallel connections to deploy your application.
- Secure - Deployer uses SSH to connect to your server.
- Supports all major PHP frameworks - Deployer supports all major PHP frameworks.
You can read more about Deployer in Getting Started.
The deploy task of Laravel consists of:
- deploy:prepare – Prepares a new release
- deploy:info – Displays info about deployment
- deploy:setup – Prepares host for deploy
- deploy:lock – Locks deploy
- deploy:release – Prepares release
- deploy:update_code – Updates code
- deploy:env – Configure .env file
- deploy:shared – Creates symlinks for shared files and dirs
- deploy:writable – Makes writable dirs
- deploy:vendors – Installs vendors
- artisan:storage:link – Creates the symbolic links configured for the application
- artisan:config:cache – Creates a cache file for faster configuration loading
- artisan:route:cache – Creates a route cache file for faster route registration
- artisan:view:cache – Compiles all of the application's Blade templates
- artisan:event:cache – Discovers and cache the application's events and listeners
- artisan:migrate – Runs the database migrations
- deploy:publish – Publishes the release
- deploy:symlink – Creates symlink to release
- deploy:unlock – Unlocks deploy
- deploy:cleanup – Cleanup old releases
- deploy:success – Deploys your project
The laravel recipe is based on the common recipe.
Configuration
shared_dirs
Overrides shared_dirs from recipe/deploy/shared.php
.
['storage']
shared_files
Overrides shared_files from recipe/deploy/shared.php
.
['.env']
writable_dirs
Overrides writable_dirs from recipe/deploy/writable.php
.
[
'bootstrap/cache',
'storage',
'storage/app',
'storage/app/public',
'storage/framework',
'storage/framework/cache',
'storage/framework/cache/data',
'storage/framework/sessions',
'storage/framework/views',
'storage/logs',
]
log_files
'storage/logs/*.log'
laravel_version
$result = run('{{bin/php}} {{release_or_current_path}}/artisan --version');
preg_match_all('/(\d+\.?)+/', $result, $matches);
return $matches[0][0] ?? 5.5;
public_path
Overrides public_path from recipe/provision/website.php
.
'public'
Tasks
artisan:down
Puts the application into maintenance / demo mode.
Maintenance mode.
artisan:up
Brings the application out of maintenance mode.
artisan:key:generate
Sets the application key.
Generate keys.
artisan:passport:keys
Creates the encryption keys for API authentication.
artisan:db:seed
Seeds the database with records.
Database and migrations.
artisan:migrate
Runs the database migrations.
artisan:migrate:fresh
Drops all tables and re-run all migrations.
artisan:migrate:rollback
Rollbacks the last database migration.
artisan:migrate:status
Shows the status of each migration.
artisan:cache:clear
Flushes the application cache.
Cache and optimizations.
artisan:config:cache
Creates a cache file for faster configuration loading.
artisan:config:clear
Removes the configuration cache file.
artisan:event:cache
Discovers and cache the application's events and listeners.
artisan:event:clear
Clears all cached events and listeners.
artisan:event:list
Lists the application's events and listeners.
artisan:optimize
Cache the framework bootstrap files.
artisan:optimize:clear
Removes the cached bootstrap files.
artisan:route:cache
Creates a route cache file for faster route registration.
artisan:route:clear
Removes the route cache file.
artisan:route:list
Lists all registered routes.
artisan:storage:link
Creates the symbolic links configured for the application.
artisan:view:cache
Compiles all of the application's Blade templates.
artisan:view:clear
Clears all compiled view files.
artisan:queue:failed
Lists all of the failed queue jobs.
Queue and Horizon.
artisan:queue:flush
Flushes all of the failed queue jobs.
artisan:queue:restart
Restarts queue worker daemons after their current job.
artisan:horizon
Starts a master supervisor in the foreground.
artisan:horizon:clear
Deletes all of the jobs from the specified queue.
artisan:horizon:continue
Instructs the master supervisor to continue processing jobs.
artisan:horizon:list
Lists all of the deployed machines.
artisan:horizon:pause
Pauses the master supervisor.
artisan:horizon:purge
Terminates any rogue Horizon processes.
artisan:horizon:status
Gets the current status of Horizon.
artisan:horizon:terminate
Terminates the master supervisor so it can be restarted.
artisan:horizon:publish
Publish all of the Horizon resources.
artisan:telescope:clear
Clears all entries from Telescope.
Telescope.
artisan:telescope:prune
Prunes stale entries from the Telescope database.
artisan:octane
Starts the octane server.
Octane.
artisan:octane:reload
Reloads the octane server.
artisan:octane:stop
Stops the octane server.
artisan:octane:status
Check the status of the octane server.
artisan:nova:publish
Publish all of the Laravel Nova resources.
Nova.
artisan:reverb:start
Starts the Reverb server.
Reverb.
artisan:reverb:restart
Restarts the Reverb server.
artisan:pulse:check
Starts the Pulse server.
Pulse.
artisan:pulse:restart
Restarts the Pulse server.
artisan:pulse:purge
Purges all Pulse data from storage.
artisan:pulse:work
Process incoming Pulse data from the ingest stream.
deploy
Deploys your project.
Main deploy task.
This task is group task which contains next tasks: