1. Go to this page and download the library: Download zheltikov/simple-migrator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zheltikov / simple-migrator example snippets
use Zheltikov\SimpleMigrator\{Config, Dialect, Migration, MigrationSet};
return new Config(
// Supply here a closure returning a PDO connection to the database
PDO: fn() => new PDO('pgsql:host=localhost;port=5432;dbname=postgres;user=postgres;password=secret'),
// Define your migrations here...
migrationSet: new MigrationSet([
new Migration(
id: '1',
up: 'CREATE TABLE people (id INTEGER);',
down: 'DROP TABLE people;',
),
new Migration(
id: '2',
up: 'ALTER TABLE people ADD COLUMN name VARCHAR;',
down: 'ALTER TABLE people DROP COLUMN name;',
),
// ...
]),
// Optionally, change the name of the migration log table.
// By default, it is 'migrations'.
tableName: 'my_migrations',
// You can also choose an SQL dialect here.
// By default, it is Dialect::POSTGRESQL
dialect: Dialect::SQLITE,
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.