Phinx Migrations

Phinx is a standalone command line tool for managing database Migrations. The official Migrations plugin for CakePHP is based on this tool.

Phinx makes it ridiculously easy to manage the database migrations for your PHP app. In less than 5 minutes, you can install Phinx using Composer and create your first database migration. Phinx is just about migrations without all the bloat of a database ORM system or application framework.

Introduction

Good developers always version their code using a SCM system, so why don’t theydo the same for their database schema?

Phinx allows developers to alter and manipulate databases in a clear andconcise way. It avoids the use of writing SQL by hand and instead offers apowerful API for creating migrations using PHP code. Developers can thenversion these migrations using their preferred SCM system. This makes Phinxmigrations portable between different database systems. Phinx keeps track ofwhich migrations have been run, so you can worry less about the state of yourdatabase and instead focus on building better software.

Goals

Phinx was developed with the following goals in mind:

  • Be portable amongst the most popular database vendors.
  • Be PHP framework independent.
  • Have a simple install process.
  • Have an easy to use command-line operation.
  • Integrate with various other PHP tools (Phing, PHPUnit) and web frameworks.

Installation

Phinx should be installed using Composer, which is a tool for dependencymanagement in PHP. Please visit the Composerwebsite for more information.

Note

Phinx requires at least PHP 5.4 (or later).

To install Phinx, simply require it using Composer:

  1. php composer.phar require robmorgan/phinx

Create folders in your project following the structure db/migrations with adequate permissions.It is where your migration files will live and should be writable.

Phinx can now be executed from within your project:

  1. vendor/bin/phinx init

Contents