diff --git a/config/routes.php b/config/routes.php index 95323cf..473b1bf 100644 --- a/config/routes.php +++ b/config/routes.php @@ -116,6 +116,9 @@ static function (ResponseFactoryInterface $responseFactory, ValidatorInterface $ Route::post('/curl/build') ->action([InspectController::class, 'buildCurl']) ->name('curl/build'), + Route::get('/config/merge-plan') + ->action([\Yiisoft\Yii\Debug\Api\Controller\ConfigController::class, 'read']) + ->name('config/merge-plan'), Group::create('/git') ->namePrefix('/git') ->routes( diff --git a/src/Controller/ConfigController.php b/src/Controller/ConfigController.php new file mode 100644 index 0000000..cfe1407 --- /dev/null +++ b/src/Controller/ConfigController.php @@ -0,0 +1,48 @@ +run()->getResult(); + $mergePlanPath = substr($output, 0, strpos($output, 'Xdebug: [Step Debug]') ?: -1); + + if (!file_exists($mergePlanPath)) { + throw new Exception( + sprintf( + 'Could not find composer.json by the path "%s".', + $mergePlanPath, + ) + ); + } + + $content = require $mergePlanPath; + $rootAlias = $aliases->get('@root'); + + $result = [ + 'path' => substr($mergePlanPath, strlen($rootAlias) + 1), + 'data' => $content, + ]; + + return $this->responseFactory->createResponse($result); + } +}