Download the PHP package kevinkl3/php-mongo-migrator without Composer

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

PHPMongo Migrator

Note: This is a fork of the original sokil/php-mongo-migrator project, updated for PHP 8.1+ compatibility. This fork replaces the deprecated sokil/php-mongo ODM with the official MongoDB PHP Library.

Migrations for MongoDB using the official MongoDB PHP Library.

Daily Downloads Latest Stable Version Coverage Status Gitter

Schema not required in MongoDb, so we dont need to create databases, collections or altering them. However there are some cases when migrations required in schemaless databases:

Requirements



Installation

Install locally through composer

After installation you will be able to run commands in console by running ./vendor/bin/mongo-migrator command.

Usage

Initialisation of migrations

Every command run in project root where composer.json and vendor dir placed. First we need to create new migration project. To do that go to project root and run:

This creates config file mongo-migrator.yaml and directory "./migrations", where migrations placed. Also you can use php config instead of yaml. Just initialise your project with php config format:

You may explicitly define path to conficuration file, and also to migration dir:

If migration dir defined relatively, it points to dir where configuration stored. In example above migrations dir will be confins/../migrations/mongo.

Configuration

Configuration format

YAML configuration file placed in file "./mongo-migrator.yaml". PHP has same structure.

Environment is set of configuration parameters, defined for concrete place, like development machine, test or production server.

Every environment has this parameters:

Environment variables in configuration

Any value may be initialised from environment variable:

Creating new revision

Now you can create your migration script. Creating new revison:

Name of revision must be in camel case format. For example run . This creates migration script like 20151127093706_RevisionName.php, where "20151127093706" is revision id and "RevisionName" is revision name.

Class source is:

Method up() filled with commands executed on migrating process, and down() - on rollback.

Now you can write code for migration and rollback.

Status of migration

If you want to see list of existed revisions with status of migration, run:

If revision status is "up", revision is applied, otherwise status will be "down".

Option configuration allows specify path to project configuration, if it differ from default path. Option length allows to limit elements in list.

Migrating and rollback

You can migrate and rollback to any of available revisions. Commands to migrate:

If revision not specified, migration goes to latest revision.

Option configuration allows specify path to project configuration, if it differ from default path.

Command to rollback:

If revision not specified, rollback goes to previous revision.

Option configuration allows specify path to project configuration, if it differ from default path.

Writing migration scripts

Databases and collections are accessible from migration scripts through methods AbstractMigration::getDatabase() and AbstractMigration::getCollection(). The method AbstractMigration::getCollection() gets a collection from the default database, defined in
environments.*.default_database parameter of config.

This library now uses the official MongoDB PHP Library. Documentation on database and collection classes may be found in the MongoDB PHP Library documentation.

What's Changed in This Fork

This fork includes the following major changes from the original project:

Migration from older versions

If you're upgrading from a version that used sokil/php-mongo, you'll need to update your migration scripts:

Old API (sokil/php-mongo) New API (mongodb/mongodb)
$collection->createDocument()->save() $collection->insertOne()
$collection->updateAll(callback) $collection->updateMany(filter, update)
$collection->find()->where('field', 'value') $collection->find(['field' => 'value'])
$collection->batchDelete(expression) $collection->deleteMany(['field' => 'value'])
$document->field $document['field'] (arrays, not objects)

For more examples, see the MongoDB PHP Library documentation.

Building Phar

1) Install box using manual at https://github.com/box-project/box2. It must be accessible as box

2) Check that composer installed and accessible in PATH

3) You may build phar in three modes: unsigned version, signed by OPENSSH (for self test on run) and signed by GPG (for installation through phive)

3.1) To build unsigned version just run make `

3.2) To build phar signed with OPENSSH, you need to have own private key. Copy it to ./keys/private.pem or generate new one:

Then build phar: `

3.3) To build phar sighen with GPG for phive, you need to place private key to ./keys/private.ask:

Then build GPG-signed phar: `

You may verify phar by public key:

Note: The MONGO_DRIVER environment variable is no longer used in this fork, as it only supports the modern MongoDB PHP extension (ext-mongodb).

Development

To start development environment in docker run:

To use xdebug, configure your IDE to use port 9001.

There is sandbox to test commands:

Unit tests

Local tests:

Docker tests:


All versions of php-mongo-migrator with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
mongodb/mongodb Version ^1.17|^2.0
symfony/console Version ^6.0|^7.0
symfony/yaml Version ^6.0|^7.0
symfony/event-dispatcher 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 kevinkl3/php-mongo-migrator contains the following files

Loading the files please wait ...