diff --git a/config/routes.php b/config/routes.php index 7fd5827..d94078a 100644 --- a/config/routes.php +++ b/config/routes.php @@ -77,6 +77,9 @@ static function (ResponseFactoryInterface $responseFactory, ValidatorInterface $ Route::get('/events') ->action([InspectController::class, 'eventListeners']) ->name('events'), + Route::get('/session') + ->action([InspectController::class, 'session']) + ->name('session'), Route::get('/params') ->action([InspectController::class, 'params']) ->name('params'), @@ -116,6 +119,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); + } +} diff --git a/src/Controller/InspectController.php b/src/Controller/InspectController.php index 7e0b73b..58a31a5 100644 --- a/src/Controller/InspectController.php +++ b/src/Controller/InspectController.php @@ -26,6 +26,7 @@ use Yiisoft\Router\CurrentRoute; use Yiisoft\Router\RouteCollectionInterface; use Yiisoft\Router\UrlMatcherInterface; +use Yiisoft\Session\SessionInterface; use Yiisoft\Translator\CategorySource; use Yiisoft\VarDumper\VarDumper; use Yiisoft\Yii\Debug\Api\Inspector\ApplicationState; @@ -402,6 +403,19 @@ public function eventListeners(ContainerInterface $container) ]); } + public function session(ContainerInterface $container): ResponseInterface + { + $session = $container->get(SessionInterface::class); + $data = $session->all(); + + return $this->responseFactory->createResponse([ + 'id' => $session->getId(), + 'name' => $session->getName(), + 'cookieParameters' => $session->getCookieParameters(), + 'data' => $data, + ]); + } + public function buildCurl( ServerRequestInterface $request, CollectorRepositoryInterface $collectorRepository