1. Go to this page and download the library: Download pccomponentes/migration 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/ */
pccomponentes / migration example snippets
declare(strict_types=1);
use Pccomponentes\Migration\Migration;
class PdoMigration implements Migration
{
private $connection;
public function __construct(\PDO $connection)
{
$this->connection = $connection;
}
public function upOperation(): void
{
$this->connection->exec('
CREATE TABLE example (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(30) NOT NULL
)
');
}
public function downOperation(): void
{
$this->connection->exec('DROP TABLE example');
}
}
#!/usr/bin/env php
onsole\Application;
use Pccomponentes\Migration\MigrationCommand;
$application = new Application();
$application->addCommands(
[
new MigrationCommand(
'pdo',
__DIR__ . '/../migration/pdo',
[
new \PDO('mysql:dbname=testdb;host=localhost;port=3306', 'user', 'password')
]
)
]
);
$application->run();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.