This document summarizes Phinx, a PHP database migration tool. It allows developers to programmatically update a database schema over time through migrations written in PHP. Key features include writing migrations, migrating up and down, seeding data, and supporting multiple databases like MySQL, PostgreSQL, and SQLite. The document provides installation instructions, best practices for writing migrations, and an overview of the tool's history and future plans.
3. “A schema migration is performed on a
database whenever it is necessary to update
or revert that database's schema to some
newer or older version. Migrations are
performed programmatically by using a
schema migration tool.”
10. Brief History
• Open Sourced in 2012 under the MIT License
• 38 Releases to Date
• 1.2 million Downloads and 115+ Contributors
• Used in CakePHP 3.0.0
• Built on top of Symfony Components (and only 3)
11. Features
• Write database migrations using PHP code
• Migrate up and down
• Seed data after database creation
• Take advantage of SCM features such as branching
• Integrate with any app
• Get going in less than 5 minutes
31. Phinx by Rob Morgan - https://phinx.org. version 0.5.3
using config file ./phinx.yml
using config parser yaml
using migration path /Users/robbym/Code/phinx/db/migrations
using seed path /Users/robbym/Code/phinx/db/seeds
using migration base class PhinxMigrationAbstractMigration
using default template
created ./db/migrations/20160309162303_create_posts_table.php
32. Phinx by Rob Morgan - https://phinx.org. version 0.5.3
using config file ./phinx.yml
using config parser yaml
using migration path /Users/robbym/Code/phinx/db/migrations
using seed path /Users/robbym/Code/phinx/db/seeds
using migration base class PhinxMigrationAbstractMigration
using default template
created ./db/migrations/20160309162303_create_posts_table.php
33. Best Practises
• Write environment agnostic code
• Version control your migrations
• Enforce default values in the migrations
themselves
• Avoid custom SQL if possible
• Use the change method by default
66. Contributing
• Before you open an issue, search the existing
ones!
• Fixing the documentation is a great place to start
• Read the CONTRIBUTING.md file on Github
• At the end of the day, nobody bites and its only
PHP!
67. Cheers!
• Rob Morgan (@_rjm_)
• https://phinx.org
• https://robmorgan.id.au
Rob Morgan
@_rjm_
#phinx #php #phptour