Skip to content

Commit

Permalink
add more opcache & php info
Browse files Browse the repository at this point in the history
  • Loading branch information
Gemorroj committed Jul 28, 2018
1 parent 6d67337 commit e43432a
Show file tree
Hide file tree
Showing 4 changed files with 200 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"require-dev": {
"phpunit/phpunit": "^7.1.2",
"phpstan/phpstan": "^0.9"
"phpstan/phpstan": "^0.10"
},
"autoload": {
"psr-4": {
Expand Down
9 changes: 9 additions & 0 deletions src/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ public function getPhp() : Php
->setExtensions(\get_loaded_extensions())
->setZendExtensions(\get_loaded_extensions(true))
->setIniFile(\php_ini_loaded_file())
->setMemoryLimit(Common::convertHumanSizeToBytes(\ini_get('memory_limit')))
->setIncludePath(\get_include_path())
->setOpenBasedir(\ini_get('open_basedir'))
->setZendThreadSafe(\ZEND_THREAD_SAFE)
->setSapiName(\PHP_SAPI)
->setDisabledFunctions($disabledFunctions ? \explode(',', $disabledFunctions) : [])
->setDisabledClasses($disabledClasses ? \explode(',', $disabledClasses) : [])
Expand All @@ -237,6 +240,12 @@ public function getPhp() : Php
->setUsedMemory($opcacheStatus['memory_usage']['used_memory'] ?? null)
->setHits($opcacheStatus['opcache_statistics']['hits'] ?? null)
->setMisses($opcacheStatus['opcache_statistics']['misses'] ?? null)
->setOomRestarts($opcacheStatus['opcache_statistics']['oom_restarts'] ?? null)
->setHashRestarts($opcacheStatus['opcache_statistics']['hash_restarts'] ?? null)
->setHashRestarts($opcacheStatus['opcache_statistics']['manual_restarts'] ?? null)
->setCachedInternedStrings($opcacheStatus['interned_strings_usage']['number_of_strings'] ?? null)
->setInternedStringsFreeMemory($opcacheStatus['interned_strings_usage']['free_memory'] ?? null)
->setInternedStringsUsedMemory($opcacheStatus['interned_strings_usage']['used_memory'] ?? null)
)
->setApcu(
(new Php\Apcu())
Expand Down
60 changes: 60 additions & 0 deletions src/Info/Php.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class Php
/** @var string */
private $includePath;
/** @var string */
private $openBasedir;
/** @var string */
private $sapiName;
/** @var Opcache */
private $opcache;
Expand All @@ -31,6 +33,46 @@ class Php
private $realpathCacheSizeUsed;
/** @var float|null */
private $realpathCacheSizeAllowed;
/** @var bool */
private $zendThreadSafe;
/** @var int */
private $memoryLimit;

/**
* @return int
*/
public function getMemoryLimit(): int
{
return $this->memoryLimit;
}

/**
* @param int $memoryLimit
* @return $this
*/
public function setMemoryLimit(int $memoryLimit): self
{
$this->memoryLimit = $memoryLimit;
return $this;
}

/**
* @return bool
*/
public function isZendThreadSafe(): bool
{
return $this->zendThreadSafe;
}

/**
* @param bool $zendThreadSafe
* @return $this
*/
public function setZendThreadSafe(bool $zendThreadSafe): self
{
$this->zendThreadSafe = $zendThreadSafe;
return $this;
}

/**
* @return string
Expand Down Expand Up @@ -122,6 +164,24 @@ public function setIncludePath(string $includePath): self
return $this;
}

/**
* @return string
*/
public function getOpenBasedir(): string
{
return $this->openBasedir;
}

/**
* @param string $openBasedir
* @return $this
*/
public function setOpenBasedir(string $openBasedir): self
{
$this->openBasedir = $openBasedir;
return $this;
}

/**
* @return string
*/
Expand Down
130 changes: 130 additions & 0 deletions src/Info/Php/Opcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,136 @@ class Opcache
private $misses;
/** @var string|null */
private $version;
/** @var int|null */
private $internedStringsUsedMemory;
/** @var int|null */
private $internedStringsFreeMemory;
/** @var int|null */
private $cachedInternedStrings;

/**
* @return int|null
*/
public function getInternedStringsUsedMemory(): ?int
{
return $this->internedStringsUsedMemory;
}

/**
* @param int|null $internedStringsUsedMemory
* @return $this
*/
public function setInternedStringsUsedMemory(?int $internedStringsUsedMemory): self
{
$this->internedStringsUsedMemory = $internedStringsUsedMemory;
return $this;
}

/**
* @return int|null
*/
public function getInternedStringsFreeMemory(): ?int
{
return $this->internedStringsFreeMemory;
}

/**
* @param int|null $internedStringsFreeMemory
* @return $this
*/
public function setInternedStringsFreeMemory(?int $internedStringsFreeMemory): self
{
$this->internedStringsFreeMemory = $internedStringsFreeMemory;
return $this;
}

/**
* @return int|null
*/
public function getCachedInternedStrings(): ?int
{
return $this->cachedInternedStrings;
}

/**
* @param int|null $cachedInternedStrings
* @return $this
*/
public function setCachedInternedStrings(?int $cachedInternedStrings): self
{
$this->cachedInternedStrings = $cachedInternedStrings;
return $this;
}

/**
* @var int|null
* number of restarts because of out of memory
*/
private $oomRestarts;
/**
* @var int|null
* number of restarts because of hash overflow
*/
private $hashRestarts;
/**
* @var int|null
* number of restarts scheduled by opcache_reset()
*/
private $manualRestarts;

/**
* @return int|null
*/
public function getOomRestarts(): ?int
{
return $this->oomRestarts;
}

/**
* @param int|null $oomRestarts
* @return $this
*/
public function setOomRestarts(?int $oomRestarts): self
{
$this->oomRestarts = $oomRestarts;
return $this;
}

/**
* @return int|null
*/
public function getHashRestarts(): ?int
{
return $this->hashRestarts;
}

/**
* @param int|null $hashRestarts
* @return $this
*/
public function setHashRestarts(?int $hashRestarts): self
{
$this->hashRestarts = $hashRestarts;
return $this;
}

/**
* @return int|null
*/
public function getManualRestarts(): ?int
{
return $this->manualRestarts;
}

/**
* @param int|null $manualRestarts
* @return $this
*/
public function setManualRestarts(?int $manualRestarts): self
{
$this->manualRestarts = $manualRestarts;
return $this;
}

/**
* @return bool
Expand Down

0 comments on commit e43432a

Please sign in to comment.