Add getLibVersion and getExtVersion method for extensions and libs

This commit is contained in:
crazywhalecc
2024-06-30 22:37:01 +08:00
committed by Jerry Ma
parent f645c8869a
commit eb00e0012f
8 changed files with 157 additions and 1 deletions

View File

@@ -10,6 +10,18 @@ use SPC\util\CustomExt;
#[CustomExt('swoole')]
class swoole extends Extension
{
public function getExtVersion(): ?string
{
// Get version from source directory
$file = SOURCE_PATH . '/php-src/ext/swoole/include/swoole_version.h';
// Match #define SWOOLE_VERSION "5.1.3"
$pattern = '/#define SWOOLE_VERSION "(.+)"/';
if (preg_match($pattern, file_get_contents($file), $matches)) {
return $matches[1];
}
return null;
}
public function getUnixConfigureArg(): string
{
// enable swoole