https://github.com/farisc0de/phpmigration
Migration Library for PHP
https://github.com/farisc0de/phpmigration
database database-migration framework migration migration-tool mysql pdo php php-library php-mysql php7
Last synced: 16 days ago
JSON representation
Migration Library for PHP
- Host: GitHub
- URL: https://github.com/farisc0de/phpmigration
- Owner: farisc0de
- License: mit
- Created: 2021-01-10T07:52:05.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-01-14T20:25:36.000Z (3 months ago)
- Last Synced: 2025-03-25T23:23:43.485Z (about 1 month ago)
- Topics: database, database-migration, framework, migration, migration-tool, mysql, pdo, php, php-library, php-mysql, php7
- Language: PHP
- Homepage:
- Size: 39.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PhpMigration
Migration Library for PHP
## How to use
```php
include_once __DIR__ . '/src/Database.php';
include_once __DIR__ . '/src/Utils.php';
include_once __DIR__ . '/src/Migration.php';
include_once __DIR__ . '/config.php';use Farisc0de\PhpMigration\Database;
use Farisc0de\PhpMigration\Options\Options;
use Farisc0de\PhpMigration\Options\Types;
use Farisc0de\PhpMigration\Utils;
use Farisc0de\PhpMigration\Migration;$obj = new Migration(new Database($config), new Utils());
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Create a new table
$obj->createTable(
"users",
[
["id", Types::Integer(), Options::AutoIncrement(), Options::NotNull()],
["username", Types::String(255), Options::NotNull()],
["password", Types::String(255), Options::NotNull()],
["email", Types::String(255), Options::NotNull()],
["created_at", Types::TimeStamp(), Options::CurrentTimeStamp()],
["updated_at", Types::TimeStamp(), Options::CurrentTimeStamp()]
]
);// Create Primary Key
$obj->setPrimary("users", "id");// Add a new record
$obj->insertValue(
"users",
[
"username" => "admin",
"password" => password_hash("admin", PASSWORD_DEFAULT),
"email" => "[email protected]",
]
);$msg = "Database installed successfully!";
```
## Copyright
FarisCode