Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add opcache page #147

Merged
merged 11 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Yiisoft\Yii\Debug\Api\Inspector\Controller\ComposerController;
use Yiisoft\Yii\Debug\Api\Inspector\Controller\GitController;
use Yiisoft\Yii\Debug\Api\Inspector\Controller\InspectController;
use Yiisoft\Yii\Debug\Api\Inspector\Controller\OpcacheController;
use Yiisoft\Yii\Middleware\CorsAllowAll;
use Yiisoft\Yii\Middleware\IpFilter;

Expand Down Expand Up @@ -171,5 +172,12 @@ static function (ResponseFactoryInterface $responseFactory, ValidatorInterface $
->action([CacheController::class, 'clear'])
->name('/clear'),
),
Group::create('/opcache')
->namePrefix('opcache')
->routes(
Route::get('[/]')
->action([OpcacheController::class, 'index'])
->name('/index'),
),
),
];
26 changes: 26 additions & 0 deletions src/Inspector/Controller/OpcacheController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace Yiisoft\Yii\Debug\Api\Inspector\Controller;

use Psr\Http\Message\ResponseInterface;
use Yiisoft\DataResponse\DataResponseFactoryInterface;

use function Safe\opcache_get_status;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a new dependency?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess, it was meant to be just opcache_get_status from root namespace. Right?


final class OpcacheController
{
public function __construct(
private DataResponseFactoryInterface $responseFactory,
) {
}

public function index(): ResponseInterface
{
return $this->responseFactory->createResponse([
'status' => opcache_get_status(true),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to verify that opcache is available.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Or else it would just crash.

'configuration' => opcache_get_configuration(),
]);
}
}
Loading