Download the PHP package daursu/laravel-zero-downtime-migration without Composer

On this page you can find all versions of the php package daursu/laravel-zero-downtime-migration. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-zero-downtime-migration

laravel-zero-downtime-migration

Zero downtime migrations with Laravel and gh-ost or pt-online-schema-change.

NOTE: works only with MySQL databases, including (Percona & MariaDB).

Installation

Compatible with Laravel 8.0, 9.0 & 10.0. For older version support, please use v1.0.

Prerequisites

If you are using gh-ost then make sure you download the binary from their releases page:

If you are using pt-online-schema-change then make sure you have percona-toolkit installed.

Installation steps

  1. Run composer require daursu/laravel-zero-downtime-migration
  2. (Optional) Add the service provider to your config/app.php file, if you are not using autoloading.

  3. Update your config/database.php and add a new connection:

This package support pt-online-schema-change and gh-ost. Below are the configurations for each package:

gh-ost
pt-online-schema-change

Usage

When writing a new migration, use the helper facade ZeroDowntimeSchema instead of Laravel's Schema, and all your commands will run through gh-ost or pt-online-schema-change.

Run php artisan:migrate

Configuration

All the configuration is done inside config/database.php on the connection itself. You can pass down custom flags to the raw pt-online-schema-change command. Simply add the parameters you want inside the params array like so:

You can find all the possible options here: https://www.percona.com/doc/percona-toolkit/LATEST/pt-online-schema-change.html

Tests

The ZeroDowntimeSchema facades allows you disable running pt-online-schema-change during tests. To do so, in your base test case TestCase.php under the setUp method add the following:

This will disable pt-online-schema-change and all the migrations using the helper facade will run through the default laravel migrator.

Custom connection name

By default, the connection name used by ZeroDowntimeSchema helper is set to zero-downtime, however you can override this if you called your connection something else in config/database.php.

To do so, in your AppServiceProvider.php add the following under the boot() method:

Replication

If your database is running in a cluster with replication, then you need to configure how pt-online-schema-changes finds your replica slaves. Here's an example setup, but feel free to customize it to your own needs

  1. Replace database_name with your database name.
  2. Create a new table called dsns

  3. Add a new row for each replica you have, example

Upgrade to v1

There is one breaking change introduced in v1, that requires to modify the configuration in database.php. The additional parameters array passed down to pt-online-schema-change or gh-ost has been renamed from options to params. This change was required as the name options conflicts with Laravel's database configuration that is automatically passed down to PDO.

Gotchas


All versions of laravel-zero-downtime-migration with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
illuminate/database Version ^8.0|^9.0|^10.0|^11.0
illuminate/support Version ^8.0|^9.0|^10.0|^11.0
symfony/console Version ^5.0|^6.0|^7.0
symfony/process Version ^5.0|^6.0|^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package daursu/laravel-zero-downtime-migration contains the following files

Loading the files please wait ....