Files
Woles-Framework/app/Core/Commands/SeedCommand.php
mwpn 0b42271bfe feat: Complete Woles Framework v1.0 with enterprise-grade UI
- Add comprehensive error handling system with custom error pages
- Implement professional enterprise-style design with Tailwind CSS
- Create modular HMVC architecture with clean separation of concerns
- Add security features: CSRF protection, XSS filtering, Argon2ID hashing
- Include CLI tools for development workflow
- Add error reporting dashboard with system monitoring
- Implement responsive design with consistent slate color scheme
- Replace all emoji icons with professional SVG icons
- Add comprehensive test suite with PHPUnit
- Include database migrations and seeders
- Add proper exception handling with fallback pages
- Implement template engine with custom syntax support
- Add helper functions and facades for clean code
- Include proper logging and debugging capabilities
2025-10-11 07:08:23 +07:00

92 lines
2.0 KiB
PHP

<?php
namespace App\Core\Commands;
use App\Core\Database\Seeder;
/**
* NovaCore Seed Command
* CLI command to run database seeders
*/
class SeedCommand
{
private string $seedersPath;
public function __construct()
{
$this->seedersPath = __DIR__ . '/../../database/seeders';
}
/**
* Execute the command
*/
public function execute(string $seeder = null): void
{
if ($seeder) {
$this->runSeeder($seeder);
} else {
$this->runAllSeeders();
}
}
/**
* Run all seeders
*/
private function runAllSeeders(): void
{
echo "Running database seeders...\n";
$seederFiles = glob($this->seedersPath . '/*.php');
foreach ($seederFiles as $file) {
$filename = basename($file);
$className = $this->getSeederClassName($filename);
require_once $file;
if (class_exists($className)) {
$seeder = new $className();
$seeder->run();
}
}
echo "Seeding completed successfully!\n";
}
/**
* Run specific seeder
*/
private function runSeeder(string $seederName): void
{
$file = $this->seedersPath . '/' . $seederName . '.php';
if (!file_exists($file)) {
echo "Error: Seeder '{$seederName}' not found\n";
return;
}
$className = $this->getSeederClassName($seederName . '.php');
require_once $file;
if (!class_exists($className)) {
echo "Error: Seeder class '{$className}' not found\n";
return;
}
echo "Running seeder: {$seederName}\n";
$seeder = new $className();
$seeder->run();
echo "Seeder completed successfully!\n";
}
/**
* Get seeder class name
*/
private function getSeederClassName(string $filename): string
{
$name = pathinfo($filename, PATHINFO_FILENAME);
return "Database\\Seeders\\{$name}";
}
}