require __DIR__ . '/./../config/service_manager.php', 'routes' => require __DIR__ . '/./../config/routes.php', ]; } } "; writeToFile($configProviderFilePath, $configProviderFileContent); // Service Manager $serviceManagerFilePath = $apiNamespacePath . '/config/service_manager.php'; $serviceManagerFileContent = " [ // Handler {$apiHandlerName}::class => AutoWiringFactory::class, // Response Formatter {$apiResponseFormatterName}::class => AutoWiringFactory::class, ], ]; "; writeToFile($serviceManagerFilePath, $serviceManagerFileContent); // Routes $routeName = strtolower($argv[2]) . '.' . strtolower($argv[3]); $routePath = strtolower($argv[2]) . '/' . strtolower($argv[3]); $routesFilePath = $apiNamespacePath . '/config/routes.php'; $routesFileContent = " '{$routeName}', 'path' => '/api/{$routePath}[/]', 'allowed_methods' => ['POST'], 'middleware' => [ {$apiHandlerName}::class, ], ], ]; "; writeToFile($routesFilePath, $routesFileContent); } if (!is_dir($cqrsNamespacePath)) { // CQRS Namespace is new, create Configs // API Namespace is new, create Configs // Config Provider $configProviderFilePath = $cqrsNamespacePath . '/src/ConfigProvider.php'; $configProviderFileContent = " require __DIR__ . '/./../config/service_manager.php', ]; } } "; writeToFile($configProviderFilePath, $configProviderFileContent); // Service Manager $serviceManagerFilePath = $cqrsNamespacePath . '/config/service_manager.php'; $serviceManagerFileContent = " [ /// CQRS // {$apiName} {$cqrsBuilderName}::class => AutoWiringFactory::class, {$cqrsHandlerName}::class => AutoWiringFactory::class, ], ]; "; writeToFile($serviceManagerFilePath, $serviceManagerFileContent); } ########## WRITE FILES ############### $apiHandlerFileContent = "getBody()->getContents(), true ); \${$cqrsVariableName} = \$this->{$cqrsBuilderVariableName}->build( \$data ); \$result = \$this->{$cqrsHandlerVariableName}->execute(\${$cqrsVariableName}); return new SuccessResponse(\$this->responseFormatter->format(\$result)); } } "; writeToFile($apiHandlerFilePath, $apiHandlerFileContent); $apiResponseFormatterFileContent = "