Download the PHP package bear/defer without Composer

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

BEAR.Defer

Continuous Integration Static Analysis

Deferred resource requests for BEAR.Resource — run resource requests after the response is transferred.

A resource accepts a request, returns 202 Accepted immediately, and the heavy follow-up work (indexing, notification, …) runs after the response has been sent to the client. The resource only declares what to defer; when and where it runs is decided by bindings, outside the resource — so the same application code works on CLI, PHP-FPM, Swoole, or a queue without change.

Design background: bearsunday/BEAR.Resource#373.

Installation

Then install DeferModule in your AppModule, passing the module that provides your responder — rename() moves that binding to the 'inner' qualifier automatically:

Usage

Declare what to defer

Annotate the accepting resource with #[Defer], listing #[Link] rels (no hardcoded URIs). Each rel's href is resolved against the resource body after the method runs. Because #[Defer] references #[Link] rels, the deferred transition stays hypermedia-driven and surfaces in ALPS as a deferred transition.

The follow-up resources are ordinary resources

They don't know they are deferred — any resource can be the target.

Conditional defer

When the follow-up work is conditional, inject DeferInterface and ResourceInterface directly and call $defer->add() manually. This bypasses #[Defer] and gives full control over what gets enqueued.

How it works

Execution strategy

The bundled SyncDefer runs deferred requests sequentially, in-process, after the transfer. It keeps request-local state in a singleton cleared on every flush(), so it is correct on PHP-FPM / CLI as long as flush() runs for every request.

The strategy is chosen by binding DeferInterface; the application code (#[Defer]) never changes.

Releasing the client connection

So the client gets its response before the deferred work runs, DeferTransfer releases the connection between the transfer and the flush, through ConnectionCloserInterface (default: SapiConnectionCloser):

A runtime with a different mechanism (e.g. Swoole's $response->end()) binds its own ConnectionCloserInterface to replace it.

Swoole / long-running workers

DeferInterface is a singleton whose queue is cleared at the request boundary by flush(). This gives per-request flushing on PHP-FPM / CLI without relying on process isolation. On a strictly coroutine-concurrent runtime where a single worker interleaves requests, per-request isolation must be provided by the runtime adapter; the core package does not address coroutine isolation.


All versions of defer with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
bear/resource Version ^1.32
ray/aop Version ^2.0
ray/di Version ^2.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 bear/defer contains the following files

Loading the files please wait ...