Download the PHP package fissible/accord without Composer

On this page you can find all versions of the php package fissible/accord. 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 accord

fissible/accord

Catch API contract violations the moment they happen — in development, in your tests, and in production.

accord checks every HTTP request and response your API handles against an OpenAPI spec, at runtime. It's a PSR-7/15 package with first-party drivers for Laravel, Slim, and Mezzio, and a framework-agnostic core you can wire into anything.


What problem does this solve?

Every API makes a promise to the apps and teams that depend on it: send me this shape of data, and I'll return that shape of data. That promise is the contract. When it quietly breaks — a field goes missing, a type changes, a list becomes an object — the clients depending on your API fail, often in ways that are hard to trace and expensive to fix.

An OpenAPI spec is a standard YAML or JSON file that writes that promise down: for each endpoint, what it accepts (query/path/header parameters and a request body) and what it returns (status codes and response bodies). It's the single source of truth for your API's shape.

accord holds your API to that spec automatically. You point it at your spec file, and it validates traffic against it in real time — catching a violation the instant it happens instead of when a downstream client breaks. You can use it two ways, and most teams use both:

accord fails open by design: anything the spec doesn't describe (an undocumented route, a missing schema) passes through untouched. It only ever enforces what your spec actually says — which makes it safe to bolt onto an API that's already running, and adopt one endpoint at a time.


Quick start (Laravel)

The service provider auto-registers via package discovery, so getting to "it's validating" takes about five minutes.

1. Install.

2. Get a spec. Drop an OpenAPI 3.0 file at resources/openapi/v1.yaml. Don't have one? Generate it from your existing routes with fissible/forge:

This documents every route and infers request-body schemas from your FormRequest rules. (Response schemas come through as empty objects — fill those in to describe what your endpoints actually return.)

3. Add the middleware to your API routes. In Laravel 11+ bootstrap/app.php:

4. Start in log mode so violations surface without breaking anything. In .env:

That's it. Hit your API and any request or response that doesn't match the spec is logged as a warning. Review those, fix the gaps (in your spec or your API), then flip to enforcing — see Setting it up properly below.


What accord can do

A tour of the capabilities, each linking to the detail:


Requirements

Installation

The Laravel service provider registers automatically. To customise configuration, publish the config file:


How it works

For each request (and its response), accord:

  1. Extracts the API version from the URI path — /v1/users → v1. (Configurable; see Version extraction.)
  2. Loads the matching spec — resources/openapi/v1.yaml. Specs are parsed once per version per process and cached in memory.
  3. Finds the operation for the request's method and path, then validates the request parameters and body, and the response status and body, against the schemas the spec defines.

If there's no version in the path, no spec for that version, no matching operation, or no schema for the content type, accord passes it through unvalidated — it enforces only what the spec describes. (Turn on diagnostics to see when and why that happens.)


Setting it up properly

The recommended path to enforcing your contract without surprises:

  1. Adopt in log mode. ACCORD_FAILURE_MODE=log surfaces every violation as a PSR-3 warning while letting all traffic through. Run it in staging (or production) and collect the real violations.
  2. Close the gaps. Each logged violation is either a spec that doesn't match reality, or an endpoint that doesn't match its spec. Fix whichever is wrong.
  3. Turn on enforcement. Once the log is quiet, switch to ACCORD_FAILURE_MODE=exception. A common production posture is to reject bad requests but only log bad responses — see Per-direction failure modes.
  4. Confirm it's actually validating. Because accord fails open, "no violations" can mean "everything's compliant" or "nothing was checked." Use assertResponseWasValidated test assertion to be sure.
  5. Keep it honest in CI. Add Continuous integration)

Configuration

The published config/accord.php (every key has an env() default, so you can drive it entirely from .env):

The rest of this section explains the knobs that need more than a one-line comment.

Failure modes

How a contract violation is handled:

Mode Behaviour
exception Throws ContractViolationException (default)
log Logs a warning via PSR-3; the request continues
callable Calls your callable with the ValidationResult; the request continues

The callable mode lets you route violations anywhere:

Per-direction failure modes

failure_mode can be a single value applied to both directions, or an array with separate request and response modes:

In the Laravel driver, a request violation under exception mode is rendered as a JSON response ({ "message": ..., "errors": [...] }) with request_violation_status (default 422; a non-4xx value falls back to 422) — a client's bad request gets a real 422, not a 500. A response violation is a server-side problem: under exception mode it surfaces as a 500, and under log mode it's logged while the original response passes through unchanged — it is never rendered as a 4xx.

Diagnostics

Because accord fails open, a missing spec, unmatched route, or undeclared schema all pass — which can hide the fact that nothing actually ran. Two tools make that visible:

Note: with validate_responses off (or a very low sample rate) and ACCORD_DEBUG on, debug logs every response as a skip — expected for a diagnostic mode, but don't run that combination in steady state.

Running it in production

Response validation runs on every response by default. Three knobs keep it cheap on high-traffic or large-payload APIs:

These show up in ACCORD_DEBUG output as excluded, response_validation_disabled, and not_sampled skips.

Caching the spec

FileSpecSource parses the OpenAPI file on every load(), and in PHP-FPM each request is a fresh process — so the (slow) YAML parse runs per request. Enable a persistent cache to parse once and rehydrate from cached JSON on subsequent requests (roughly an order of magnitude faster):

Two caveats:

For Slim/Mezzio, pass a PSR-16 cache instance directly: AccordFactory::make(['spec_cache' => $psr16, ...], $basePath).

Loading specs from a URL

Set spec_source to url and provide a pattern with a {version} token:

Useful when specs are managed externally or shared across services. Fetched specs are cached in memory per process; enable spec_cache to persist them across restarts (recommended for serverless).

Path & content-type matching

accord matches the request path against your spec's path templates as-is first. If nothing matches, it also tries stripping each root-level servers base path — so a spec with servers: [{url: /v2}] and a relative path /users matches a request to /v2/users. (Stripping is segment-safe: /v20/... is not treated as under /v2. Path-item/operation-level servers overrides are not considered, and the API version must still appear in the request path or be matched by your version_pattern.)

Content types are matched exact-first, then by wildcard: a request/response application/json matches a spec that declares application/* or */* (exact declarations always win).

Version extraction

By default the version is taken from the URI path:

URI Extracted version Spec file
/v1/users v1 resources/openapi/v1.yaml
/v2/orders/99 v2 resources/openapi/v2.yaml
/users (none — passes unconstrained) —

Change the pattern via version_pattern; capture group 1 must match the version number.

Spec files

Place your OpenAPI 3.0 specs at:

JSON is also supported. When the path pattern has no extension, accord tries .yaml, .yml, and .json in that order.


Testing your API against the contract

The same validation, available as a test assertion — so a drifting API fails CI. Add the AssertsApiContracts trait and call it after any API request:

assertResponseMatchesContract fails if the response violates the spec. assertResponseWasValidated fails (naming the skip reason) if the response was silently skipped — pair them to avoid "green because nothing validated."


Slim

Or use the core middleware directly if you're wiring the validator yourself:

Mezzio

Or register via your container:


Extending

Custom spec sources

FileSpecSource (local files) and UrlSpecSource (remote) ship in the box. For anything else — a database, a registry, an internal API — implement SpecSourceInterface:

For reference, the built-in file and URL sources:

Custom framework drivers

To integrate accord with a framework not covered by the bundled drivers, implement DriverInterface:


The Fissible suite

accord is the foundation of a family of focused PHP packages for keeping your API and its documentation honest with each other. You only need accord for runtime validation — the rest are optional companions you add as your needs grow.


Continuous integration

Pair accord with fissible/drift to turn contract drift into a build failure. accord:validate exits non-zero when the app's routes have drifted from the spec (a route added but undocumented, or removed but still in the spec):

GitHub Actions

drift:coverage is an optional second check — it verifies every registered route has a real controller (not just a closure), catching skeleton routes that were never wired up.

GitLab CI


License

MIT


All versions of accord with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
cebe/php-openapi Version ^1.7
nyholm/psr7 Version ^1.8
psr/http-message Version ^1.1|^2.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
psr/log Version ^2.0|^3.0
psr/simple-cache Version ^2.0|^3.0
symfony/psr-http-message-bridge Version ^2.0|^7.0
symfony/yaml Version ^6.0|^7.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 fissible/accord contains the following files

Loading the files please wait ...