Download the PHP package leemason/polycast without Composer

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

Polycast

Packagist License Latest Stable Version Total Downloads

Laravel Websocket broadcasting polyfill using ajax and mysql. Laravel 5.1 or Later

Installation

Require this package with composer:

After updating composer, add the ServiceProvider to the providers array in config/app.php

Laravel 5.1:

Add the following in your broadcasting connections array located in config/broadcasting.php

Copy the package assets to your public folder with the publish command:

Migrate the packages database migrations (creates the polycast_events table):

Usage

To Optionally set Polycast as your default broadcast events driver set as the default in your config/broadcasting.php or in your .env file.

Once installed you create broadcastable events exactly the same as you do now (using the ShouldBroadcast trait), except you have a way to consume those events via browsers without the need for nodejs/redis or an external library to be installed/purchased.

This package doesn't aim to compete with libraries or solutions such as PRedis/SocketIO/Pusher. But what it does do is provide a working solution for situations where you can't install nodejs and run a websocket server, or where the cost of services like Pusher aren't feasible.

The package utilizes vanilla javascript timeouts and ajax requests to "simulate" a realtime experience. It does so by saving the broadcastable events in the database, via a setTimeout javascript ajax request, polls the packages receiver url and distrubutes the payloads via javascript callbacks.

To add to the simulation of realtime events each event found is parsed from the time its requested, and when the event was fired. The difference in seconds is then used to delay the callbacks firing on that specific event.

What this does is prevent every event callback dumping into the dom when the ajax request has completed, but instead fires then in sequence as if it was loading live.

To the user the only real difference to websockets is that they will be a few seconds behind (depending on the polling option provided "default 5 seconds").

I have tried to keep the javascript api similar to current socket solutions to reduce the learning curve.

Here's an example:

Breaking down the example you can see we include the library:

Create a Polycast object inside a self executing function (this can be done a few ways, and has a few options):

We register any callbacks on the connection events:

We create channel objects by subscribing to the channel:

And we register callbacks for specific events fired on those channels:

Should something go wrong, or you need to disconnect you can at any point in time:

And that's it! (for now)

Bower Usage

The polycast package is registered on Bower using the name and can be installed by running:

The package script can then be accessed from the path.

NPM Usage

The polycast package is registered on npm using the name and can be installed by running:

The package script can then be accessed from the path.

Webpack Usage

The polycast package script files are generated using gulp/webpack, this offers advantages when developing your javascript via script loaders.

Usage is as follows:

The package is still in early development (but is stable) so expect new methods and features soon.

FAQ

Does this require jQuery?

Nope, all vanilla js here including the ajax requests.

What if there is a problem during the request? Will my javascript enter a loop?

Nope, the next setTimeout call wont happen until the previous one has been compeleted.

How does it work out what events get sent to who?

This is done by the channel and event names, but the package also monitors times. When the js service creates a connection the server sends back its current time. This is stored in the js object and is sent/updated on subsequent requests creating a "events named ? on channel ? since ?" type database query.

Notes

The is my first real javascript heavy package, which is great as it gives me more opportunity to learn the language. That being said if there are any improvements you could make please let me know or send a pull request.

The Future


All versions of polycast with dependencies

PHP Build Version
Package Version
Requires illuminate/support Version 5.1.*|5.2.*
illuminate/database Version 5.1.*|5.2.*
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 leemason/polycast contains the following files

Loading the files please wait ....