Download the PHP package zerifas/ladder without Composer
On this page you can find all versions of the php package zerifas/ladder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zerifas/ladder
More information about zerifas/ladder
Files in zerifas/ladder
Package ladder
Short Description A database migration tool, written in PHP.
License MIT
Informations about the package ladder
Ladder
What is it?
Ladder started life many years ago as an extremely simple database migration system. It's grown over time to include a host of features. It's written for PHP >= 8.0, and supports the popular MySQL database server via PDO.
What would I use this for?
It's used in conjunction with source control (Git, Mercurial, SVN, et al) in order to track the changes made to the database alongside application source code.
This allows multiple developers to work on a project and know whether or not they have the correct database schema for their local development environments, and enables them to bring their schema up-to-date with a single command.
Migrations have at least two methods: apply()
and rollback()
. The apply()
method
is run when the migration is applied, and rollback()
when it is un-applied.
Logically, a rollback()
method should do the opposite to its counterpart apply()
method; Dropping a column instead of adding it, etc.
What is supported?
- Creating and dropping tables
- Adding, dropping, and altering columns
- Adding and dropping indexes/constraints
- Data operations: insert/update/delete
- Storing metadata when applying a migration, and using it during rollback
How do I use it?
You can add Ladder to your project using Composer:
Your ladder.json
file should look something like the included ladder.json.sample
:
If your database does not exist, and your user has access to create it, init
will do so:
Now, you should be able to run the status
command to see what's not applied, and migrate
to apply changes.
You can get Ladder to create a migration template file for you:
The template shows an example of creating and dropping a table, edit and save the file, and then:
Additionally, you can provide a migration id to the migrate
command in order to migrate to that specific point.
The migrate
command can be used to migrate to an older migration only when given the --rollback
option. This is to avoid accidentally dropping tables or columns.
Commands
Ladder aims to be self-documenting in use (though we need documentation for the Migration methods):
Example Migration
Here's an example that does way too much for a single Migration, but should cover all the use cases.
All versions of ladder with dependencies
pimple/pimple Version ^3.0
symfony/event-dispatcher Version ^2.8
symfony/console Version ^2.8
zerifas/collections Version ^1.1
zerifas/json Version ^2.0