Download the PHP package nikovonlas/yii2sockets without Composer

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

Node.js server integration module (web-sockets)

Install with composer

Add console command controller to the config (controllerMap section):

Add session component to the 'components' section of main config:

It uses Redis DB connection to share session data with Node.js server. Of course you must use redis component to connect Redis DB. Add it in both configs (web and main).

And add component do those configs (https not implemented yet):

Parameter channelsByPermissions is an array with channel names and permissions. If Yii::$app->user->can('permission') returns TRUE than channel channel_name will be added to user automatically. It runs on component init.

When configs are ready use console command to build Node.js config files:

Node.js server

Server is in server subdirectory. Before first run you must install all Node.js modules. Go to server directory and install they with command

Now you can run server

You can use environment variables to overwrite config options. For example:

In that case it runs in production mode with disabled debug information.

Messages

There are 3 message classes (I call it Frames):

  1. Basic (YiiNodeSocketFrameBasic) used for basic messages.

  2. jQuery (YiiNodeSocketFrameJQuery) used for jQuery DOM manipulations.

  3. Notify (YiiNodeSocketFrameGrowl) uses kartik-v/yii2-widget-growl to show messages for user.

  4. Alert (YiiNodeSocketFrameAlert) plays audio alert to user.

Examples

Send message with array[] body to channel test_channel. On front end will be used Javascript callback jsCallbackName.

Send message to this socket (example is used on AJAX request).

Send jQuery frame to user with ID 1. It will remove element with selector #element_selector.

Send Alert frame to channel test_channel to all browser windows (not active too):

Please notice, that you need to render block with <audio> element in order to play it.

Also includes example YiiNodeSocketFrameChat frame type that sends message depending on its content:

  1. to recipient_id and author_id if object contains both those properties;
  2. to channel composed automatically otherwise. You can see frame source for details.

Javascript callback example:


All versions of yii2sockets with dependencies

PHP Build Version
Package Version
Requires yiisoft/yii2 Version *
yiisoft/yii2-redis Version *
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 nikovonlas/yii2sockets contains the following files

Loading the files please wait ....