Download the PHP package riskio/idempotency-module without Composer

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

Idempotency module for Zend Framework

Zend Framework module ensuring at most once requests for mutating endpoints.

Latest Stable Version Build Status Total Downloads

While the inherently idempotent HTTP semantics around PUT and DELETE are a good fit for many API calls, what if we have an operation that needs to be invoked exactly once and no more? An example might be if we were designing an API endpoint to charge a customer money; accidentally calling it twice would lead to the customer being double-charged, which is very bad.

This is where idempotency keys come into play. When performing a request, a client generates a unique ID to identify just that operation and sends it up to the server along with the normal payload. The server receives the ID and correlates it with the state of the request on its end. If the client notices a failure, it retries the request with the same ID, and from there it’s up to the server to figure out what to do with it.

Stripe describes its solution in a blog post which provided the inspiration for this package.

Requirements

Installation

Idempotency module only officially supports installation through Composer. For Composer documentation, please refer to getcomposer.org.

You can install the module from command line:

After installation of the package, you have to copy the riskio_idempotency.global.php.dist file into your config/autoload folder and apply any setting you want.

Zend Framework

In Zend Framework application, you must enable the module by adding Riskio\IdempotencyModule in your application.config.php file.

Zend Expressive

In Zend Expressive application, you must add the Riskio\IdempotencyModule\IdempotencyMiddleware middleware in config/pipeline.php file at the very first pipeline records.

Documentation

The module goal is to guarantee the safety of operations on mutating endpoints by allowing clients to pass a unique value with the special Idempotency-Key header.

The clients are in charge of creating the unique keys. The module always send back the same response for requests made with the same key, and keys can't be reused with different request parameters.

Idempotency key format validation

By default, the module uses V4 UUIDs but you can change validation rules using the config file seen above:

Storage of already performed requests

In order to keep track of requests performed with Idempotency-Key header, you have to specify a PSR-6 cache compliant service. Keys will expire after a delay related to the lifetime of your cache.

For instance, Stripe has defined that the keys expire after 24 hours.

Idempotent requests serialization/deserialization

For each idempotent request, the module creates an instance of that contains a checksum of the HTTP request performed and the related HTTP response in order to be stored and eventually retrieved in the future if the request is made more than once.

Accordindly, we must provide a serializer that will serialize and unserialize this class. By defaut, the module uses the class but you can provide another one if you want.

Eligible HTTP methods

RFC7231 (substituting RFC2616) added two notions to HTTP methods:

Method Safe Idempotent
GET yes yes
HEAD yes yes
POST no no
PUT no yes
PATCH no no
DELETE no yes

Accordingly to the RFC, only POST and PATCH HTTP methods are not idempotent. Consequently, the module allows clients to use Idempotent-Key header only for these methods by default. However, you can configure another HTTP method list to meet your needs as below:

Idempotency key header customization

By default, the module uses Idempotency-Key header to submit unique tokens that guarantee idempotency of endpoints. If you want to use another header name for whatever reason, you can specify it as below:

Testing

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of idempotency-module with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0
psr/cache Version ^1.0
symfony/cache Version ^3.0
zendframework/zend-diactoros Version ^1.1
zendframework/zend-eventmanager Version ^2.6.3 || ^3.0
zendframework/zend-http Version ^2.6
zendframework/zend-mvc Version ^3.0
zendframework/zend-psr7bridge Version ^1.0
zendframework/zend-stdlib Version ^2.7.3 || ^3.0
zendframework/zend-validator Version ^2.0
http-interop/http-middleware Version ^0.4.1
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 riskio/idempotency-module contains the following files

Loading the files please wait ....