New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

brainstud/laravel-deployment-scripts

Create one time deployment scripts to run at the next release
11,587 1
Install
composer require brainstud/laravel-deployment-scripts
Latest Version:v2.0.0
PHP:^8.5
Laravel:12 · 13
Older releases:8 – 11
License:MIT
Last Updated:Apr 16, 2026
Links: GitHub  ·  Packagist
Maintainer: Diondb

Introduction

When deploying new code you'll sometimes need to execute one time scripts, commands or queries to activate new functionalities. With a growing application, it is easy to lose sight of which things should be executed for a given deployment. Laravel already has migrations which run after executing the artisan migrate command, but these migrations are aimed at database operations only.

The Laravel one time deployment scripts package aims to solve this problem by offering a migration-like way of registering scripts, commands and queries that should be executed. By simply registering the deployment scripts execute command, the package will check whether there are any scripts that should be executed. Once a script has been executed it will be registered in the database so that it won't run again.

Example

The code snippet below is an example of how the deployment script is configured. A regular or an anonymous class is created which extends the DeploymentScript base class. Then it registers the up and down methods to contain the deployment tasks that need to be executed, and finally within those methods the desired tasks are executed.

return new class extends DeploymentScript {
	public function up()
	{
		$this->command('mycommand:trigger');

		$this->query('UPDATE `table` SET `foo` = 1 WHERE `baz` IS NULL');
	}
	
	public function down()
	{
		$this->closure(function () {
			(new CustomActionClass())->execute();
		});
	}
} 

Installation

You can install the package via composer:

composer require brainstud/laravel-deployment-scripts

You can publish and run the migrations with:

php artisan vendor:publish --tag="deployment-scripts-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="deployment-scripts-config"

This is the content of the published config file:

return [
    'table_name' => 'deployment_scripts_log',
];

Usage

Available commands

Command Description
deployment-script:make {name} Create a new deployment script class
deployment-script:execute Execute the deployment scripts
deployment-script:rollback Roll back the deployment scripts by one iteration

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

License

The MIT License (MIT). Please see License File for more information.

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

648,266,899 9,701
laravel/framework

The Laravel Framework.

604,216,237 34,982
laravel/tinker

Powerful REPL for the Laravel framework.

512,508,631 7,443
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

429,221,767 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

403,217,078 4,664

Version History

Version Released PHP Laravel License
v2.0.0 ^8.5 ^12.0||^13.0 MIT
v1.0.4 ^8.2 ^10|^11|^12 MIT
v1.0.3 ^8.2 ^8.73|^9|^10|^11 MIT
v1.0.2 ^8.1 ^8.73|^9|^10 MIT
v1.0.1 ^8.0 ^8.73|^9 MIT