PHP code example of piko / migrate

1. Go to this page and download the library: Download piko/migrate 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/ */

    

piko / migrate example snippets




return [
    'DSN' => 'mysql:host=127.0.0.1;dbname=test;charset=utf8mb4',
    'DB_USERNAME' => 'my_user',
    'DB_PASSWORD' => 'my_password',
];



return new class {
    public function up(PDO $db): void
    {
        $db->exec('CREATE TABLE users (id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(120) NOT NULL)');
    }

    public function down(PDO $db): void
    {
        $db->exec('DROP TABLE users');
    }
};
bash
composer install
php ./bin/migrate --help