
How to Run One-Time and Repeatable Tasks After Laravel Deployment
Run Laravel deployment tasks once or on every deploy, track execution, coordinate servers, and understand queued jobs and rollback with practical examples.
Laravel Executor turns the steps you run after every deploy into versioned files. Write an executor once, run php artisan execute in your deploy script, and every server runs exactly the tasks it still needs, recorded in batches you can roll back.
One file per task and one command in your deploy script.
Mark an executor ExecutorType::ONCE to run it a single time, or ALWAYS to run it on every deploy.
Call Artisan with $this->command() and dispatch queued jobs with $this->job() from up().
Every run is recorded in a batch, and execute:rollback calls down() on the latest batches.
Tag executors and run a subset with php artisan execute --tags=cache,search.
List server names or IPs in $servers to keep an executor to the machines it belongs on, with one record per server.
execute:status shows every executor with its type, tags, servers, batch and whether it ran.
An executor that rebuilds the caches on every deploy, on the web servers only.
1use Pharaonic\Laravel\Executor\Classes\Executor; 2use Pharaonic\Laravel\Executor\Enums\ExecutorType; 3 4return new class () extends Executor { 5 public $type = ExecutorType::ALWAYS; 6 public $tags = ['cache']; 7 public $servers = ['10.0.0.11', '10.0.0.12']; 8 9 public function up(): void10 {11 $this->command('optimize');12 $this->command('view:cache');13 }14 15 public function down(): void16 {17 $this->command('optimize:clear');18 }19};Quick answers about installing and using Executor.
Run deployment tasks in Laravel once or on every deploy: Artisan commands, queued jobs and data fixes, tracked in batches with rollback, tags, server targeting and a cross-server lock. It's a free, open-source Laravel package by Pharaonic.
Run composer require pharaonic/laravel-executor in your project's root directory, then php artisan migrate.
The latest release requires PHP 8.3+ and Laravel 13.
Migrations change the database schema. Executors run anything else a deploy needs, such as Artisan commands, queued jobs or data fixes, and can run once or on every deploy.
Run it in your deploy script after php artisan migrate, on every server. Each server runs only the executors it still needs.
php artisan execute takes a lock in the executors table, so the servers run the executors one after another and a ONCE executor runs only once. Every server that shares the table shares the lock, with no cache setup.
Yes. Create them with php artisan make:executor Name --path=other/folder, and register the folder with Executor::getPool()->addPath(base_path('other/folder')) in a service provider.
Yes. Executor is open source under the MIT license, so you can use it in personal and commercial projects.
Read the Executor documentation for setup, configuration, and usage examples.
Open an issue or a pull request on GitHub, or ask in the Pharaonic Discord.
Practical guides that use Laravel Executor, or solve the problem it was built for.

Run Laravel deployment tasks once or on every deploy, track execution, coordinate servers, and understand queued jobs and rollback with practical examples.
Read the full documentation for installation, configuration, writing executors, running, rolling back and inspecting them, tags and server targeting, the API reference, and the upgrade guide.