Search by

adachsoft / api-version-bundle

Arkadiusz Adach

A Symfony bundle that exposes the running application's version through a JSON API endpoint.

Package info

gitlab.com/a.adach/api-version-bundle

Issues

Type:symfony-bundle

pkg:composer/adachsoft/api-version-bundle

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.0 2026-11-06 12:39 UTC

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/version with 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.