adachsoft / api-version-bundle
A Symfony bundle that exposes the running application's version through a JSON API endpoint.
Package info
gitlab.com/a.adach/api-version-bundle
Type:symfony-bundle
pkg:composer/adachsoft/api-version-bundle
Requires
- php: ^8.3 || ^8.4
- ext-json: *
- symfony/framework-bundle: ^7.0 || ^8.0
- symfony/http-foundation: ^7.0 || ^8.0
- symfony/routing: ^7.0 || ^8.0
- zircote/swagger-php: ^5.0 || ^6.0
Requires (Dev)
- adachsoft/php-code-style: ^0.7.1
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^13.4
- rector/rector: ^2.8
- symplify/phpstan-rules: ^14.9
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-11-07 06:45:53 UTC
README
A Symfony bundle that exposes the running application's version through a JSON API endpoint.
Features
- Serves
GET /api/v1/versionwith the application version and optional application name. - Reads the version from a JSON changelog file by default.
- Includes Composer-installed and static version providers, plus an interface for custom providers.
- Documents the endpoint with OpenAPI attributes.
Requirements
- PHP 8.3 or newer
- Symfony FrameworkBundle 7 or 8
Installation
composer require adachsoft/api-version-bundle
Register the bundle in config/bundles.php if your application does not register bundles automatically:
<?php
return [
// ...
AdachSoft\ApiVersionBundle\ApiVersionBundle::class => ['all' => true],
];
Add the endpoint to config/routes/api_version.yaml:
api_version:
path: /api/v1/version
controller: AdachSoft\ApiVersionBundle\Controller\GetVersionController
methods: [GET]
Configure the optional application name and changelog path in config/packages/api_version.yaml:
api_version:
name: 'catalog-api'
changelog_path: '%kernel.project_dir%/changelog.json'
The changelog_path option defaults to %kernel.project_dir%/changelog.json. The JSON file must contain either a string current_version value or a non-empty releases list whose first item has a string version value. For example:
{
"current_version": "1.2.3"
}
Response
A successful request returns HTTP 200:
{
"version": "1.2.3",
"name": "catalog-api"
}
If the configured version source is unavailable, the endpoint returns HTTP 503:
{
"error": {
"message": "Version provider unavailable."
}
}
See docs/examples/ for complete Symfony setup and provider examples.
License
This library is distributed under the MIT license. See LICENSE.