Download the PHP package clue/connection-manager-extra without Composer

On this page you can find all versions of the php package clue/connection-manager-extra. 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 connection-manager-extra

clue/reactphp-connection-manager-extra

CI status installs on Packagist

This project provides extra (in terms of "additional", "extraordinary", "special" and "unusual") decorators, built on top of ReactPHP's Socket.

Table of Contents

Support us

We invest a lot of time developing, maintaining and updating our awesome open-source projects. You can help us sustain this high-quality of our work by becoming a sponsor on GitHub. Sponsors get numerous benefits in return, see our sponsoring page for details.

Let's take these projects to the next level together! 🚀

Introduction

If you're not already familar with react/socket, think of it as an async (non-blocking) version of fsockopen() or stream_socket_client(). I.e. before you can send and receive data to/from a remote server, you first have to establish a connection - which takes its time because it involves several steps. In order to be able to establish several connections at the same time, react/socket provides a simple API to establish simple connections in an async (non-blocking) way.

This project includes several classes that extend this base functionality by implementing the same simple ConnectorInterface. This interface provides a single promise-based method connect($uri) which can be used to easily notify when the connection is successfully established or the Connector gives up and the connection fails.

Because everything uses the same simple API, the resulting Connector classes can be easily interchanged and be used in places that expect the normal ConnectorInterface. This can be used to stack them into each other, like using delaying SSL/TLS connections, randomly picking a Connector or any combination thereof.

Usage

This section lists all features of this library along with some examples. The examples assume you've installed this library and already set up a Socket/Connector instance $connector.

All classes are located in the ConnectionManager\Extra namespace.

Repeat

The ConnectionManagerRepeat($connector, $tries) tries connecting to the given location up to a maximum of $tries times when the connection fails.

If you pass a value of 3 to it, it will first issue a normal connection attempt and then retry up to 2 times if the connection attempt fails:

Timeout

The ConnectionManagerTimeout($connector, $timeout, $loop = null) sets a maximum $timeout in seconds on when to give up waiting for the connection to complete.

Delay

The ConnectionManagerDelay($connector, $delay, $loop = null) sets a fixed initial $delay in seconds before actually trying to connect. (Not to be confused with ConnectionManagerTimeout which sets a maximum timeout.)

Reject

The ConnectionManagerReject(null|string|callable $reason) simply rejects every single connection attempt. This is particularly useful for the below ConnectionManagerSelective to reject connection attempts to only certain destinations (for example blocking advertisements or harmful sites).

The constructor accepts an optional rejection reason which will be used for rejecting the resulting promise.

You can explicitly pass a string value which will be used as the message for the Exception instance:

You can explicitly pass a callable value which will be used to either throw or return a custom Exception instance:

Swappable

The ConnectionManagerSwappable($connector) is a simple decorator for other ConnectionManagers to simplify exchanging the actual ConnectionManager during runtime (->setConnectionManager($connector)).

Consecutive

The ConnectionManagerConsecutive($connectors) establishes connections by trying to connect through any of the given ConnectionManagers in consecutive order until the first one succeeds.

Random

The ConnectionManagerRandom($connectors) works much like ConnectionManagerConsecutive but instead of using a fixed order, it always uses a randomly shuffled order.

Concurrent

The ConnectionManagerConcurrent($connectors) establishes connections by trying to connect through ALL of the given ConnectionManagers at once, until the first one succeeds.

Selective

The ConnectionManagerSelective($connectors) manages a list of Connectors and forwards each connection through the first matching one. This can be used to implement networking access control lists (ACLs) or firewall rules like a blacklist or whitelist.

This allows fine-grained control on how to handle outgoing connections, like rejecting advertisements, delaying unencrypted HTTP requests or forwarding HTTPS connection through a foreign country.

If none of the entries in the list matches, the connection will be rejected. This can be used to implement a very simple whitelist like this:

If you want to implement a blacklist (i.e. reject only certain targets), make sure to add a default target to the end of the list like this:

Similarly, you can also combine any of the other connectors to implement more advanced connection setups, such as delaying unencrypted connections only and retrying unreliable hosts:

Each entry in the list MUST be in the form host or host:port, where host may contain the * wildcard character and port may be given as either an exact port number or as a range in the form of min-max. Passing anything else will result in an InvalidArgumentException.

Note that the host will be matched exactly as-is otherwise. This means that if you only block youtube.com, this has no effect on www.youtube.com. You may want to add a second rule for *.youtube.com in this case.

Install

The recommended way to install this library is through Composer. New to Composer?

This project follows SemVer. This will install the latest supported version:

See also the CHANGELOG for details about version upgrades.

This project aims to run on any platform and thus does not require any PHP extensions and supports running on legacy PHP 5.3 through current PHP 8+ and HHVM. It's highly recommended to use the latest supported PHP version for this project.

Tests

To run the test suite, you first need to clone this repo and then install all dependencies through Composer:

To run the test suite, go to the project root and run:

License

This project is released under the permissive MIT license.

Did you know that I offer custom development services and issuing invoices for sponsorships of releases and for contributions? Contact me (@clue) for details.


All versions of connection-manager-extra with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3
react/event-loop Version ^1.2
react/promise Version ^3 || ^2.1 || ^1.2.1
react/promise-timer Version ^1.9
react/socket Version ^1.12
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 clue/connection-manager-extra contains the following files

Loading the files please wait ....