modulesPath = __DIR__ . '/../../Modules'; } /** * Execute the command */ public function execute(string $moduleName): void { if (!$moduleName) { echo "Error: Module name is required\n"; echo "Usage: php artisan make:module \n"; return; } $modulePath = $this->modulesPath . '/' . $moduleName; $viewPath = "{$modulePath}/view"; // Create directories if (!is_dir($modulePath)) { mkdir($modulePath, 0755, true); } if (!is_dir($viewPath)) { mkdir($viewPath, 0755, true); } // Create Controller $this->createController($moduleName, $modulePath); // Create Model $this->createModel($moduleName, $modulePath); // Create Routes $this->createRoutes($moduleName, $modulePath); // Create View $this->createView($moduleName, $viewPath); echo "Module '{$moduleName}' created successfully!\n"; echo "Controller: {$modulePath}/Controller.php\n"; echo "Model: {$modulePath}/Model.php\n"; echo "Routes: {$modulePath}/routes.php\n"; echo "View: {$viewPath}/index.php\n"; } /** * Create controller file */ private function createController(string $moduleName, string $modulePath): void { $controllerContent = "view('{$moduleName}.view.index', [ 'title' => '{$moduleName} - NovaCore Framework' ]); } }"; file_put_contents("{$modulePath}/Controller.php", $controllerContent); } /** * Create model file */ private function createModel(string $moduleName, string $modulePath): void { $modelContent = "get('/{$moduleName}', '{$moduleName}\\Controller@index');"; file_put_contents("{$modulePath}/routes.php", $routesContent); } /** * Create view file */ private function createView(string $moduleName, string $viewPath): void { $viewContent = " {{ \$title }}

{{ \$title }}

Welcome to the {$moduleName} module!

"; file_put_contents("{$viewPath}/index.php", $viewContent); } }