Skip to content

Commit

Permalink
Check if opcache is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
xepozz committed Jul 6, 2024
1 parent 27527f4 commit 426f0b0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Inspector/Controller/OpcacheController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

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

use function Safe\opcache_get_status;
use Yiisoft\Http\Status;

final class OpcacheController
{
Expand All @@ -18,9 +17,15 @@ public function __construct(

public function index(): ResponseInterface
{
if (!\function_exists('opcache_get_status') || ($status = \opcache_get_status(true)) === false) {
return $this->responseFactory->createResponse([
'message' => 'OPcache is not installed or configured',
], Status::UNPROCESSABLE_ENTITY);
}

return $this->responseFactory->createResponse([
'status' => opcache_get_status(true),
'configuration' => opcache_get_configuration(),
'status' => $status,
'configuration' => \opcache_get_configuration(),
]);
}
}

0 comments on commit 426f0b0

Please sign in to comment.