Download the PHP package lucinda/migrations without Composer

On this page you can find all versions of the php package lucinda/migrations. 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 migrations

Lucinda Migrations

Table of contents:

About

This API serves as platform able to automate data migration between development environments (eg: changes in database structure) useful in systems powered by continuous integration/delivery. Modeled on Symfony DoctrineMigrationsBundle operations, it performs its task in a starkly different way:

Methodology Used

When developing this API I asked myself: what do all migrations, regardless of what they migrate, have in common? Following aspects came to my mind:

This API only performs the logistics for API-level operations above without taking any assumption on:

Migration operations supported will be:

Note that unlike DoctrineMigrationsBundle, diff and dump-schema operations will not be supported by default because they make both subject and implementation assumption (that SQL database is subject and that DAO implementation uses ORM model).

Implementation

True to its goal of creating a migration skeleton for specialization to be built upon, this API only defines common logistics:

API is fully PSR-4 compliant, only requiring PHP 8.1+ interpreter and Console Table API (for displaying migration results on console). All classes inside belong to namespace Lucinda\Migration! To quickly see how it works, check:

To insure reliability, API has been fully unit tested using Unit Testing API, as you can see in tests folder. To run unit tests by yourselves, run these commands:

Installation

To install this API, go to your project root and run:

Then create a migrations.php script that will execute migrations:

Setting Cache

Implementing migration Cache is outside the scope of skeleton API, which makes no assumption on what is the subject of migrations or how should cache be stored (eg: could be MySQL, could be Amazon DynamoDB).

An example of a SQL Data Access API , using a MySQL table to store info:

Code for SQL function used above:

Execution

Once a Cache is implemented, you can complete migration script and perform migrations. Example using the two classes in previous section:

Above example will work if:

You can now go to folder where API was installed and execute generate commands, go to migrations folder and fill up/down methods accordingly. Once at least one migration Script is filled, you will be able to execute migrations from console.

To maximize flexibility, developers that do not want to use console output provided by Wrapper directly and handle output by themselves.

Console Commands

API allows following console commands:

Argument#1 Argument#2 Description
generate Generates a template Script class in migrations folder outputs its name
migrate (default) Loops through all Script classes in migrations folder and executes their up method
up (classname) Runs up method for Script identified by its class name
down (classname) Runs down method for Script identified by its class name

How does generate command work

This will generate a migration Script class in migrations folder. Open that class and fill up and down methods with queries, as in this example:

Example:

This will output name of Script created in migrations folder whose up/down methods you must fill.

How does migrate command work

When migrate is ran, API will locate all Cache:

If up throws no Throwable, migration is saved in Throwable message will be shown to caller in results summary.

Example:

The end will be a console table with following columns:

How does up command work

When up (commit) command is ran, API will first check if Script name received as 2nd argument exists on disk in migrations folder:

Example:

The end result will be a console table with following columns:

How does down command work

When down (rollback) command is ran, API will first check if Script name received as 2nd argument exists on disk in migrations folder:

Example:

The end result will be a console table with following columns:

Reference Guide

This guide includes all classes, enums and interfaces used by API.

Cache

Interface Lucinda\Migration\Cache defines operations a cache that saves migration Lucinda\Migration\Scripts execution progress must implement. It defines following methods:

Method Arguments Returns Description
exists bool Checks cache exists physically
create void Creates cache if not exists
read string[Status] Gets Status
add string, Status void Inserts or updates Status
remove string void Removes Script from cache by class name

Script

Interface Lucinda\Migration\Script defines operations a migration script must implement, corresponding to following methods:

Method Arguments Returns Description
up Commits migration to destination
down Rolls back migration from destination

In case an error has occurred, methods are expected to bubble a Throwable, which will inform API that they ended with an error. Following recommendations apply:

Result

Class Lucinda\Migration\Result encapsulates results of a Lucinda\Migration\Script execution. Following public methods are relevant for developers:

Method Arguments Returns Description
getClassName string Gets Script class name
getStatus Status Gets status code associated with results of up/down command
getThrowable Throwable Gets throwable class name if Status is FAILED

Generally you won't need to use this class unless you're building your own results displayer on top of Wrapper!

Status

Enum Lucinda\Migration\Status contains list of migration execution Result statuses:

Case Description
PENDING Script has been scheduled for execution
FAILED Throwable
PASSED Script execution was successful

Wrapper

Class Lucinda\Migration\Wrapper performs API task of creating, locating and executing migration Cache as a result. Following public methods are defined:

Method Arguments Returns Description
__construct string $folder, Cache $cache Sets up API for migration based on folder to migration files
generate string Generates a migration class (see more)
migrate Result[] Executes up command for all see more)
up string $className Result Executes up command for script identified by classname (Exception if class not found or already in PASSED state
down string $className Result Executes down command for script identified by classname (Exception if class not found or not in PASSED state

To increase reusability, API makes no assumptions how results will be displayed so this class is strictly a model on whom various displayers may be built!

ConsoleExecutor

Class Lucinda\Migration\ConsoleExecutor makes the assumption you will like to envelop see more). It comes with following public methods:

Method Arguments Returns Description
__construct string $folder, Cache $cache Sets up Wrapper underneath
execute string $operation, string $className Executes a Wrapper method and displays results in console

When execute method is used:


All versions of migrations with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
lucinda/console Version ~2.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 lucinda/migrations contains the following files

Loading the files please wait ....