Download the PHP package philiprehberger/laravel-api-versioning without Composer

On this page you can find all versions of the php package philiprehberger/laravel-api-versioning. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-api-versioning

Laravel API Versioning

Tests Latest Version on Packagist Last updated

Laravel middleware for API versioning with multi-source resolution from headers, Accept vendor types, and URL path segments.

Requirements

Installation

Laravel's package auto-discovery registers the service provider automatically.

Publish the config file:

This creates config/api-versioning.php.

Usage

Configuration

Registering the Middleware

Accessing the Current Version

Version Resolution Priority

  1. X-API-Version request header
  2. Accept header vendor type: application/vnd.{vendor_name}.{version}+json
  3. URL path segment: /api/{version}/...
  4. Configured default version

API

Method / Concept Description
ApiVersion::current(Request $request) Get the resolved API version for the current request
ApiVersion::aliases() Get the configured version aliases as an associative array
ApiVersion::resolveAlias(string $alias) Resolve an alias to its version string, or null if not found
ApiVersion::isDeprecated(string $version) Check whether a version is deprecated (in deprecated_versions or not the latest_version)
ApiVersion middleware Resolves version (with alias support), sets request attribute, adds response headers
X-API-Version response header The resolved version for each request
X-API-Deprecated response header true / false — whether this version is deprecated

Version Aliases

Map friendly names to version strings so clients can request latest or stable instead of a specific version number:

When the middleware resolves a version that matches an alias key, it transparently replaces it with the target version. For example, sending X-API-Version: latest is treated as X-API-Version: v2.

You can also resolve aliases programmatically:

Deprecation Checks

Check whether a version is deprecated programmatically:

SemVer-Style Versions

In addition to the simple v1, v2 form, the URL path and Accept header resolvers also match SemVer-style versions like v1.2, v1.2.3, etc. List them in supported_versions to enable:

Custom Accept Header Pattern

Override the default application/vnd.{vendor_name}.{version}+json matcher with a custom regex via accept_header_pattern. The first capture group must contain the version string:

When accept_header_pattern is null, the default vendor type pattern is used.

Response Headers

Header Values Meaning
X-API-Version v1, v2, ... The resolved version for this request
X-API-Deprecated true / false Whether this version is deprecated

Unsupported Version Response (400)

Development

Support

If you find this project useful:

⭐ Star the repo

🐛 Report issues

💡 Suggest features

❤️ Sponsor development

🌐 All Open Source Projects

💻 GitHub Profile

🔗 LinkedIn Profile

License

MIT


All versions of laravel-api-versioning with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/config Version ^11.0|^12.0
illuminate/http Version ^11.0|^12.0
illuminate/support Version ^11.0|^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package philiprehberger/laravel-api-versioning contains the following files

Loading the files please wait ...