1. Go to this page and download the library: Download initphp/barbarian 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/ */
initphp / barbarian example snippets
declare(strict_types=1);
namespace App\Migrations;
use InitPHP\Barbarian\MigrationAbstract;
use InitPHP\Barbarian\QueryInterface;
final class Migration_20240101000000 extends MigrationAbstract
{
public function up(QueryInterface $query): bool
{
$query->query('CREATE TABLE IF NOT EXISTS `users` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`email` VARCHAR(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;');
return true;
}
public function down(QueryInterface $query): bool
{
$query->query('DROP TABLE IF EXISTS `users`');
return true;
}
}
use InitPHP\Barbarian\Migrations;
$pdo = new PDO('mysql:host=localhost;dbname=test;charset=utf8mb4', 'root', '');
$migrations = new Migrations($pdo, __DIR__ . '/migrations', [
'migrationTable' => 'migrations_versions',
'namespace' => 'App\\Migrations', // use null for the global namespace
]);
// Apply (up) a single migration:
$migrations->upMigration(new \App\Migrations\Migration_20240101000000());
// Revert (down) a single migration:
$migrations->downMigration(new \App\Migrations\Migration_20240101000000());
// Or iterate over every discovered migration:
foreach ($migrations->getMigrations() as $version => $class) {
$migrations->upMigration(new $class());
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.