Download the PHP package gaiatools/content-accord without Composer
On this page you can find all versions of the php package gaiatools/content-accord. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gaiatools/content-accord
More information about gaiatools/content-accord
Files in gaiatools/content-accord
Package content-accord
Short Description Laravel package for API versioning with composable strategies and generic negotiation dimensions
License MIT
Homepage https://github.com/GaiaTools/content-accord
Informations about the package content-accord
Content Accord
Content Accord is a Laravel package for API versioning with composable strategies and a generic negotiation layer. It supports URI, header, and Accept header versioning behind a single fluent API and prepares your application for future negotiation dimensions (locale, format, tenant).
Features
- URI, custom header, or Accept header versioning
- Optional resolver chaining (try multiple strategies in order)
- Configurable missing-version behavior
- Per-route-group fallback when the requested version is missing
- Deprecation headers with sunset and documentation links
- Attribute-driven version metadata on controllers and methods
- Generic negotiation foundation for future dimensions
Requirements
- PHP 8.3+
- Laravel 12+ (Laravel 11 and 13 are supported via constraints)
Installation
Publish the configuration file:
Configuration
The main configuration lives in config/content-accord.php under the versioning key.
Key settings:
dimensions: array of dimension services to negotiatestrategy:uri,header, oracceptresolver: custom resolver class/binding for versioningchain: array of strategies to try in ordermissing_strategy:reject,default,latest, orrequiredefault_version: used when missing strategy isdefaultfallback: global default for version fallbackversions: registered versions and deprecation metadata
Usage
Fluent Route Groups (Recommended)
Use Route::apiVersion() to declare versioned route groups. The URI prefix is
managed automatically based on your configured resolver strategy.
With the URI strategy (default), the above registers at /api/v1/users and
/api/v2/users. With header or Accept strategies, both register at /api/users
and Content Accord selects the right route at dispatch time.
Deprecation metadata is a fluent chain:
Header Strategy
Requests:
Accept Header Strategy
Custom Dimensions and Resolvers
Override the negotiated dimensions or the resolver implementation:
Register any custom dimensions/resolvers in the container so they can be resolved.
Missing Version Behavior
Configure what happens when a request has no version:
Fallback Behavior
Enable fallback globally or per group:
If a request targets v3 but only v2 exists for that endpoint, the v2 route will be selected when fallback is enabled.
Attributes
Add version metadata on controllers or methods:
Method-level attributes take precedence over class-level attributes. Attribute versions override the group version in route metadata. Mismatches are logged in local/testing environments.
Deprecation Headers
Mark version groups as deprecated and optionally add sunset dates and docs links:
The Deprecation, Sunset, and Link headers are added automatically when deprecation metadata is present.
Accessing the Negotiated Version
Use the apiVersion() helper in controllers or anywhere after the negotiate
middleware has run:
Or inject NegotiatedContext directly:
Testing Utilities
Use the testing helper to attach API versions to test requests:
The helper respects the configured strategy (URI, header, or Accept).
Artisan Command
List configured versions and route counts:
License
MIT
All versions of content-accord with dependencies
illuminate/contracts Version ^11.0|^12.0
illuminate/http Version ^11.0|^12.0
illuminate/routing Version ^11.0|^12.0
illuminate/support Version ^11.0|^12.0