Download the PHP package madbyad/mpl-long-poll without Composer

On this page you can find all versions of the php package madbyad/mpl-long-poll. 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 mpl-long-poll

MPL Long Poll

The MPL (MadByAd PHP Library) Long Poll is a library purposely created for providing an easy interface to implement a real time communication with HTTP Long Polling. Although HTTP Long Polling may be an outdated technique (because of WebSocket), it is easier to implement in PHP rather than Websocket, and can be used to create a seamless real time communication (though there may be slight delay in seconds)

LongPoll Class

The LongPoll class is used to provide an easy way to implement real time communication with HTTP Long Polling

informPeer()

The LongPoll::informPeer(string $id, array $data) method is used for sending a message (data) to the given peer. This method takes 2 parameter, the first is the peer id and the second is the data which should be in an associative array

readAsPeer()

The LongPoll::readAsPeer(string $id, bool $endExecution = true) method is used for reading message (data) as the given peer. This method takes 1 parameter and 1 optional parameter, the parameter is the peer id and the optional parameter determine whether to end the execution after reading the message (data) by default it is set to TRUE

setQueryTime()

The LongPoll::setQueryTime(int $second) method is use to set the query time (in seconds) the lower the query time the more responsive it is but more resource intensive it will be, the higher the query time the less responsive it is but less resource intensive it will be

setJsonFlags()

The LongPoll::setJsonFlags(int $flags) method is use to set the how the JSON message is formatted (only for debugging use). The list of avaible format is

Example

Here is two example of How Long Polling works

Example 1

First we will create read.php and we will write

Now if we execute read.php with the php read.php you will notice that the script won't stop executing, thats because Long Polling is a technique were you only send 1 request and then the server will keep querying until it gets a message and after that it will return the message, or in this case we execute the script once and the script will keep querying until it gets a message and after that it will stop and return the message

Now go ahead and create send.php and write

Now if we open a new terminal and execute php send.php "Hello World" you will notice that the first terminal will immediately stop or stop after a while which depends on the query time you have set to and output something like this

thats because when the script querries a message, it detected a message and thus it will output the message and stop the execution

this is essentially how real time communication with HTTP Long Polling works. The client only send 1 request to the server, then the server will receive the request and began querrying / checking for message every n second, and if a message does exist, it will immediately return the message to the client, and when the client receive the message it will send another request to check new messages

Example 2

Here is another example, this time instead of closing after receiveng a message we will continue messaging

First we will create read.php and we will write

In this example we set the second parameter to FALSE which means instead of stopping it will continue to execute

Now if we open a new terminal and execute php send.php "Hello World" after a while the first terminal should receive the message. Something like this

and instead of stopping it will continue. now if we open a new terminal and execute php send.php "Hello World" after a while the first terminal should receive the message

Now in the second terminal go ahead an execute php send.php "How Are you?" after a while the first terminal should receive the message

Well done you have succesfully communicated with two terminal

To end process simply kill the terminal


All versions of mpl-long-poll with dependencies

PHP Build Version
Package Version
Requires php Version >= 7.0.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 madbyad/mpl-long-poll contains the following files

Loading the files please wait ....