Download the PHP package aniart-solutions/bitrix-migrations without Composer

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

Latest Stable Version Total Downloads License PHP Version

Bitrix-migrations

Database migrations for Bitrix CMS and more

Installation

1) composer require aniart-solutions/bitrix-migrations

2) cp vendor/aniart-solutions/bitrix-migrations/migrator migrator - copy the executable file to a convenient location.

3) Open the file and make sure that $_SERVER['DOCUMENT_ROOT'] is set correctly. Change settings if needed.

4) php migrator install

This command will create a table in the database to store the names of executed migrations.

By default:

1) The table is called migrations.

2) composer.json and migrator are located in the site root.

3) Migration files will be created in the ./migrations directory relative to the file copied in step 2.

If necessary, all of this can be changed in the copied migrator file.

Usage

Workflow

The workflow is done through the console and is briefly described as follows:

1) Create a migration file (or files) using php migrator make migration_name

A migration file is a class with two methods: up() and down()

2) Implement the necessary database changes in the up() method. Optionally, implement rollback of these changes in the down() method.

3) Apply available migrations - php migrator migrate

4) Add migration files to version control so they can be run on other machines.

Available Commands

You can get a list of available commands in the console - php migrator list

CommandDescription
`php migrator install` Creates a table to store migrations. Run once.
`php migrator make migration_name` Creates a migration file Options:
`-d foo/bar` - specify a subdirectory in which the migration will be created
`php migrator migrate` Applies all available migrations. Previously applied migrations are not applied.
`php migrator rollback` Rolls back the last migration (the `down()` method). After that, it can be applied again.
Options:
`--hard` - perform a hard rollback without calling the `down()` method
`--delete` - delete the migration file after rollback.
`php migrator templates` Shows a detailed table with all existing migration templates
`php migrator status` Shows available migrations to run, as well as the last executed ones.
`php migrator archive` Moves all migrations to archive. By default, this is the `archive` directory, but it can be overridden in the config by specifying "dir_archive"
Options:
`-w 10` - do not archive the last N migrations

Migration Templates

Since changing the Bitrix database structure through its API is extremely unpleasant, there is a migration template mechanism to facilitate this process, which works as follows: When generating a migration file, you can specify its template: php migrator make migration_name -t add_iblock where add_iblock is the template name. A class with a boilerplate from the template will be generated and you only need to specify the details (for example, the name and code of the infoblock) You can add your own migration templates directly in the migrator file using TemplateCollection::registerTemplate()

Available templates:

NameDescriptionAliases
`default` Clean default template
`add_iblock_type` Adding an infoblock type
`add_iblock` Adding an infoblock
`add_iblock_element_property` Adding a property to an infoblock `add_iblock_prop`, `add_iblock_element_prop`, `add_element_prop`, `add_element_property`
`add_uf` Adding a UF property
`query` Custom database query via D7 API
`add_table` Creating a table via D7 API `create_table`
`delete_table` Deleting a table via D7 API `drop_table`

Automatic Migration Creation

Another killer feature is the automatic migration creation mode. To enable it, add something like the following to init.php

The path to the directory similar to the config in the migrator file is passed to the Manager::init() method.

After that, when performing a number of actions in the admin panel, the following will happen:

1) A Bitrix event handler is triggered

2) A migration file is created as with php migrator make

3) The migration is marked as applied

4) A notification about the previous points is shown

Enabling this mode allows you to get rid of manually writing migrations for many cases. Nothing needs to be edited in automatically created migrations.

List of handled events:

EventComments
Adding an infoblock
Updating infoblock base fields Due to the specifics of the Bitrix admin panel, this migration is often created when it's not needed, for example when adding a custom property to an infoblock. Nothing fatal, but you have to accept it.
Deleting an infoblock
Adding a custom property to an infoblock
Updating an infoblock custom property Migration is created only if any of the property attributes were changed
Deleting an infoblock custom property
Adding a UF property anywhere (infoblock section, user, highload block) Unfortunately, Bitrix does not allow tracking changes to such a property - only addition and deletion
Deleting a UF property
Adding a highload block
Updating a highload block Migration is created only if any of the highload block attributes were changed
Deleting a highload block
Adding a user group
Updating a user group
Deleting a user group

Migration Error Handling

To cancel a migration during its execution, it is enough to throw an exception - Neither the migration itself nor subsequent ones will be applied.

Usage Outside Bitrix

The package is created for use with Bitrix, but it can be easily used in other systems as well. To do this, you need to in the migrator file:

1) Replace the Bitrix core connection with the core of another system.

2) Implement your own analogue of AniartSolutions\BitrixMigrations\Repositories\BitrixDatabaseRepository; and use it.

3) Optionally disable existing migration templates by creating your own.


All versions of bitrix-migrations with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1.0,<8.5.0
symfony/console Version ^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 aniart-solutions/bitrix-migrations contains the following files

Loading the files please wait ...