Download the PHP package mpyw/co without Composer

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

Co Build Status Coverage Status Scrutinizer Code Quality

Asynchronous cURL executor simply based on resource and Generator

PHP :question: Feature Restriction
7.0~ :smile: Full Support
5.5~5.6 :anguished: Generator is not so cool
~5.4 :boom: Incompatible

The requests are executed as parallelly as possible :smile:
Note that there is only 1 process and 1 thread.

Table of Contents

Installing

Install via Composer.

And require Composer autoloader in your scripts.

API

Co::wait()

Wait for all the cURL requests to complete.
The options will override static defaults.

Arguments

Key Default Description
throw true Whether to throw or capture CURLException or RuntimeException on top-level.
pipeline false Whether to use HTTP/1.1 pipelining.
At most 5 requests for the same destination are bundled into single TCP connection.
multiplex true Whether to use HTTP/2 multiplexing.
All requests for the same destination are bundled into single TCP connection.
autoschedule false Whether to use automatic scheduling by CURLMOPT_MAX_TOTAL_CONNECTIONS.
interval 0.002 curl_multi_select() timeout seconds. 0 means real-time observation.
concurrency 6 Limit of concurrent TCP connections. 0 means unlimited.
The value should be within 10 at most.

When autoschedule Disabled:

When autoschedule Enabled:

The details of CURLIFNO_*_TIME timing charts are described at the bottom of this page.

Return Value

(mixed)
Resolved values; in exception-safe context, it may contain...

Exception

Co::async()

Execute cURL requests along with Co::wait() call, without waiting resolved values.
The options are inherited from Co::wait().

This method is mainly expected to be used ...

Arguments

Return Value

(null)

Exception

Co::isRunning()

Return if Co::wait() is running().
With this check, you can safely call Co::wait() or Co::async().

Co::any()
Co::race()
Co::all()

Return a Generator that resolves with specific value.

Family Return Value Exception
Co::any() First Success AllFailedException
Co::race() First Success First Failure

Co::setDefaultOptions()
Co::getDefaultOptions()

Overrides/gets static default settings.

Rules

Conversion on Resolving

The all yielded/returned values are resolved by the following rules.
Yielded values are also resent to the Generator.
The rules will be applied recursively.

Before After
cURL resource curl_multi_getconent() result or CURLException
Array Array (with resolved children) or RuntimeException
Generator Closure
Generator
Return value (after all yields done) or RuntimeException

"Generator Closure" means Closure that contains yield keywords.

Exception-safe or Exception-unsafe Priority

Context in Generator

Exception-unsafe context by default.
The following yield statement specifies exception-safe context.

This is equivalent to:

Context on Co::wait()

Exception-unsafe context by default.
The following setting specifies exception-safe context.

This is equivalent to:

Context on Co::async()

Contexts are inherited from Co::wait().
The following setting overrides parent context as exception-safe.

The following setting overrides parent context as exception-unsafe.

Pseudo-sleep for Each Coroutine

The following yield statements delay the coroutine processing:

Comparison with Generators of PHP7.0+ or PHP5.5~5.6

return Statements

PHP 7.0+:

PHP 5.5~5.6:

Although experimental aliases Co::RETURN_ Co::RET Co::RTN are provided,
Co::RETURN_WITH is recommended in terms of readability.

yield Statements with Assignment

PHP 7.0+:

PHP 5.5~5.6:

finally Statements

Be careful that return triggers finally while yield Co::RETURN_WITH => does not.

Appendix

Timing Charts

Note that S is equal to Q when autoschedule is disabled.

Basic

ID When
Q curl_multi_exec() immediately after curl_multi_add_handle() called
S Processing started actually
DNS DNS resolution completed
TCP TCP connection established
TLS TLS/SSL session established
HS All HTTP request headers sent
BS Whole HTTP request body sent
HR All HTTP response headers received
BR Whole HTTP response body received
Constant Time
CURLINFO_NAMELOOKUP_TIME DNS - S
CURLINFO_CONNECT_TIME TCP - S
CURLINFO_APPCONNECT_TIME TLS - S
CURLINFO_PRETRANSFER_TIME HS - S
CURLINFO_STARTTRANSFER_TIME HR - S
CURLINFO_TOTAL_TIME BR - Q

With Redirections by CURLOPT_FOLLOWLOCATION

ID When
Q curl_multi_exec() immediately after curl_multi_add_handle() called
S Processing started actually
DNS(1) DNS resolution completed
TCP(1) TCP connection established
TLS(1) TLS/SSL session established
HS(1) All HTTP request headers sent
BS(1) Whole HTTP request body sent
HR(1) All HTTP response headers received
DNS(2) DNS resolution completed
TCP(2) TCP connection established
TLS(2) TLS/SSL session established
HS(2) All HTTP request headers sent
BS(2) Whole HTTP request body sent
HR(2) All HTTP response headers received
BR(2) Whole HTTP response body received
Constant Time
CURLINFO_REDIRECT_TIME HR(1) - Q
CURLINFO_NAMELOOKUP_TIME DNS(2) - HR(1)
CURLINFO_CONNECT_TIME TCP(2) - HR(1)
CURLINFO_APPCONNECT_TIME TLS(2) - HR(1)
CURLINFO_PRETRANSFER_TIME HS(2) - HR(1)
CURLINFO_STARTTRANSFER_TIME HR(2) - HR(1)
CURLINFO_TOTAL_TIME BR(2) - Q

All versions of co with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.0
lib-curl Version >=7.20.0
ext-reflection Version *
react/promise Version ^2.4
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 mpyw/co contains the following files

Loading the files please wait ....