Download the PHP package rhubarbphp/module-migrations without Composer

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

Migrations Module

Commonly, when applications are upgraded there are breaking changes that require a scripted solution. This module provides a framework to: quickly generate migration scripts; manage the local version of an instance of your application, and; run migration scripts in order to bring your local version up-to-date with the current project version.

Setting the application version

The current application version needs to be defined when your project is initialized. The version must be an integer.

class MyApplication extends Application
{
    public function initialise()
    {
        // ...
        $this->version = 12; 
        // ...
    }
}

Creating a migration script

A migration script must implement the MigrationScriptInterface.

execute() is the logic of the migration.

version() must return an integer and defines on which application version this script should be executed. Migrations are executed in an order of version. Migrations on the same version are executed in the order they are registered.

class ImageDeletionScript extends MigrationScript
{
        public function execute()
        {
            foreach (Image::all(new Equals('active', false)) as $image) {
                unlink($image->filePath);
                $image->delete();
            }
        }

        public function version(): int
        {
            return 17;
        }
}

Registering your script

Scripts will not be ran unless they are registered. Scripts are registered by calling registerMigrationScripts($scriptsArray) on MigrationsModule.

   MigrationsManager::getMigrationsManager()->registerMigrationScripts([
       SplitNameColumnScript::class,
       DeleteAllImagesScript::class,
       UpdatedGdprInfoScript::class
   ]);

Custard Commands

migrations:migrate

The primary migrate command. All registered migration scripts with a version of or between the current locally stored version and the application version defined in code will be loaded and executed.

Options
Option shortcut Description
Skip Scripts -s It is possible to skip certain scripts, for example if you are re-running a failed migration and do not want to include the failing script. To do so include the option -s followed by the full path of the script to skip. You can include multiple scripts with -s.
Example

custard migrations:migrate -s My\Project\Scripts\NewMigrationScript.php -s My\Project\Scripts\DestroyOldDataScript.php

migrations:run-script

Takes the full path of a script and immediately executes it.

Example

custard migrations:run-script My\Project\Scripts\NewMigrationScript.php

MigrationsManager

The MigrationsManager is used to register and retrieve Migration Scripts. It's core function is to provide a set of active, valid and ordered migration scripts within a range via the getMigrationScripts() function.

The MigrationsManager implemented the Singleton trait and can be accessed via MigrationsManager::getMigrationsManager()

MigrationsStateProvider

The MigrationsStateProvider handles the current local version of the application and which migration scripts have been run. It must implement the following methods:

getLocalVersion() retrieves the local version. Must return an integer.

setLocalVersion(int $newLocalVersion) updates the local version.

markScriptCompleted(MigrationScriptInterface $migrationScript) locally stores a script as having been successfully executed.

isScriptComplete(string $className) checks if a script has already been successfully executed.

getCompletedScripts()


All versions of module-migrations with dependencies

PHP Build Version
Package Version
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 rhubarbphp/module-migrations contains the following files

Loading the files please wait ....