Complete Phase 1: MVC, DB migrations, Auth, RBAC, Security, and Views
This commit is contained in:
62
cli.php
Normal file
62
cli.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
die("This script can only be run from the command line.");
|
||||
}
|
||||
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
// Bootstrap Environment configurations
|
||||
if (file_exists(__DIR__ . '/.env')) {
|
||||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
|
||||
$dotenv->load();
|
||||
}
|
||||
|
||||
use App\Core\Container;
|
||||
use App\Services\Database\Connection;
|
||||
use App\Services\Database\MigrationRunner;
|
||||
use Database\Seeds\DatabaseSeeder;
|
||||
|
||||
$container = new Container();
|
||||
|
||||
// Singletons configurations
|
||||
$container->singleton(Connection::class, Connection::class);
|
||||
$container->singleton(MigrationRunner::class, MigrationRunner::class);
|
||||
$container->singleton(DatabaseSeeder::class, DatabaseSeeder::class);
|
||||
|
||||
$args = $argv;
|
||||
$command = $args[1] ?? 'help';
|
||||
|
||||
switch ($command) {
|
||||
case 'migrate':
|
||||
echo "=== Running Migrations ===\n";
|
||||
try {
|
||||
$runner = $container->get(MigrationRunner::class);
|
||||
$runner->migrate();
|
||||
} catch (\Throwable $e) {
|
||||
echo "Migration failed: " . $e->getMessage() . "\n";
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'seed':
|
||||
echo "=== Running Database Seeder ===\n";
|
||||
try {
|
||||
$seeder = $container->get(DatabaseSeeder::class);
|
||||
$seeder->seed();
|
||||
} catch (\Throwable $e) {
|
||||
echo "Seeding failed: " . $e->getMessage() . "\n";
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'help':
|
||||
default:
|
||||
echo "ScoutIQ CLI Utility\n";
|
||||
echo "Usage: php cli.php [command]\n\n";
|
||||
echo "Commands:\n";
|
||||
echo " migrate Run SQL database migrations\n";
|
||||
echo " seed Seed the database with default data\n";
|
||||
echo " help Show this help menu\n";
|
||||
break;
|
||||
}
|
||||
Reference in New Issue
Block a user