diff --git a/composer.json b/composer.json index b9b2569..dc19038 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "24unix/bindapi", "description": "manage Bind9 DNS server via REST API", "version": "1.0.9", - "build_number": "366", + "build_number": "367", "authors": [ { "name": "Micha Espey", diff --git a/src/Controller/RequestController.php b/src/Controller/RequestController.php index cd8c208..d64922a 100644 --- a/src/Controller/RequestController.php +++ b/src/Controller/RequestController.php @@ -58,6 +58,7 @@ class RequestController // server tag + private string $baseDir; #[OAT\Get( path: '/ping', @@ -113,7 +114,15 @@ class RequestController { if ($this->validateApiKey()) { $this->status = '200 OK'; - $this->response = '1.2.3'; + + $composerJson = json_decode(json: file_get_contents(filename: $this->baseDir . 'composer.json')); + $version = $composerJson->version; + $buildNumber = $composerJson->build_number; + + $this->result = [ + 'version' => $version, + 'buildnumber' => $buildNumber, + ]; } else { $this->status = '401 Unauthorized'; $this->message = 'API key is missing or invalid'; @@ -653,6 +662,8 @@ class RequestController private readonly EncryptionController $encryptionController, private readonly Logger $logger) { + $this->baseDir = dirname(path: __DIR__, levels: 2) . '/'; + $this->status = ''; $this->response = ''; $this->message = ''; diff --git a/src/Util/Console.php b/src/Util/Console.php index f4d9996..79c7060 100644 --- a/src/Util/Console.php +++ b/src/Util/Console.php @@ -39,11 +39,11 @@ if (array_key_exists(key: 'v', array: $options) || array_key_exists(key: 'versio $authorName = $authors[0]->name; $authorEmail = $authors[0]->email; - echo 'Name: $name' . PHP_EOL; - echo 'Description: $description' . PHP_EOL; - echo 'Version: $version' . PHP_EOL; - echo 'Build Number: $buildNumber' . PHP_EOL; - echo 'Author: $authorName ($authorEmail)' . PHP_EOL; + echo "Name: $name" . PHP_EOL; + echo "Description: $description" . PHP_EOL; + echo "Version: $version" . PHP_EOL; + echo "Build Number: $buildNumber" . PHP_EOL; + echo "Author: $authorName ($authorEmail)" . PHP_EOL; exit(0); }