Skip to content

Commit 8559597

Browse files
authored
Merge pull request #7 from OpenConext/feature/info-opcache
Add opcache information to the info endpoint when available
2 parents 90909df + 8f7843d commit 8559597

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

src/Controller/InfoController.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ class InfoController
5454
*/
5555
private $debuggerEnabled;
5656

57+
/**
58+
* @var array
59+
*/
60+
private $systemInfo = [];
61+
5762
public function __construct(
5863
$buildPath,
5964
$environment,
@@ -62,14 +67,19 @@ public function __construct(
6267
$this->buildPath = $buildPath;
6368
$this->environment = $environment;
6469
$this->debuggerEnabled = $debuggerEnabled;
70+
71+
if (function_exists('opcache_get_status')) {
72+
$this->systemInfo['opcache'] = opcache_get_status(false);
73+
}
6574
}
6675

6776
public function infoAction()
6877
{
6978
$info = Information::buildFrom(
7079
BuildPathFactory::buildFrom($this->buildPath),
7180
$this->environment,
72-
$this->debuggerEnabled
81+
$this->debuggerEnabled,
82+
$this->systemInfo
7383
);
7484

7585
return JsonResponse::create($info);

src/Value/Information.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,36 @@ class Information implements JsonSerializable
4141
*/
4242
private $debuggerEnabled;
4343

44+
/**
45+
* @var array
46+
*/
47+
private $systemInfo;
48+
4449
/**
4550
* @param BuildPath $buildPath
4651
* @param $environment
4752
* @param $debuggerEnabled
4853
* @return Information
4954
*/
50-
public static function buildFrom(BuildPath $buildPath, $environment, $debuggerEnabled)
55+
public static function buildFrom(BuildPath $buildPath, $environment, $debuggerEnabled, array $systemInfo)
5156
{
5257
Assert::stringNotEmpty($environment, 'Environment must have a non empty string value');
5358
Assert::boolean($debuggerEnabled, 'Debugger enabled must have a boolean value');
5459

55-
return new self($buildPath, $environment, $debuggerEnabled);
60+
return new self($buildPath, $environment, $debuggerEnabled, $systemInfo);
5661
}
5762

5863
/**
5964
* @param BuildPath $buildPath
6065
* @param string $environment
6166
* @param bool $debuggerEnabled
6267
*/
63-
public function __construct(BuildPath $buildPath, $environment, $debuggerEnabled)
68+
public function __construct(BuildPath $buildPath, $environment, $debuggerEnabled, array $systemInfo)
6469
{
6570
$this->buildPath = $buildPath;
6671
$this->environment = $environment;
6772
$this->debuggerEnabled = $debuggerEnabled;
73+
$this->systemInfo = $systemInfo;
6874
}
6975

7076
public function jsonSerialize()
@@ -73,6 +79,7 @@ public function jsonSerialize()
7379
'build' => $this->buildPath->getPath(),
7480
'env' => $this->environment,
7581
'debug' => $this->debuggerEnabled,
82+
'system' => $this->systemInfo,
7683
];
7784

7885
if ($this->buildPath->hasRevision()) {

0 commit comments

Comments
 (0)