Download the PHP package ratacibernetica/yii2-node-socket without Composer

On this page you can find all versions of the php package ratacibernetica/yii2-node-socket. 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 yii2-node-socket

Disclaimer

This fork is under development to make it work with Yii2. As of now, i haven't checked the subscription feature, Many parts of code have been rewritten and tested only in a project, so i guess this doesn't work not out of the box .

Be warned.

Yii2 Node Socket

Connect php, javascript, nodejs in one Yii application.

Yii1

Hi, if you need work with yii1 you can do it from (https://github.com/oncesk/yii-node-socket/tree/2.0.0)

What you can do:

Changes

Requirements

Installation

Install nodejs, if not installed see http://nodejs.org/
Install extension

Now go to the folder where you install extension vendors/ratacibernetica/yii2-node-socket and execute

Yii2 configuration

Notice: host should be a domain name like in you virtual host configuration or server ip address if you request page using ip address

Notice: if you will be using behaviors or node-socket models, you need to add nodeSocket component in preload components list

Install nodejs components in application.ext.yii-node-socket.lib.js.server:

Congratulation, installation completed!

Notice: if the name of the component will not be nodeSocket, your need to use special key in console command --componentName=component_name

Notice: It's highly probable that the JS don't load by itself, so we must register the YiiSocketNode Assets in the view/layout.

Like so.

Console command actions (as administrative user)

Use (./yii node-socket/)

Definitions

About Yii2's User model

We need to follow these steps to send events to certain Users:

Register these Events

As Yii2 doesnt have those events anymore, we need to add them.

So i created a file named "AppBootstrap":

And add it, indeed, to frontend/config/main.php

So, we just subscribed the logged user to node's service (or something like that, not sure).

Events

Work in javascript

Use YiiNodeSocket class

Start work

Catch Events

Now events can be created only on PHP side. All data transmitted in json format. Into callback function data was pasted as javascript native object (or string, integer, depends of your PHP Frame config)

Rooms

Channels

Channel is very similar to the room, but you can controll access to channel for clients

Emit events

You can emit event to:

Global events:

Room event:

Shared Public Data

You can set shared data only from PHP using PublicData Frame (see below into PHP section). To access data you can use getPublicData(string key, callback fn) method

PHP

Behaviors

Client authorization

For authorizing client you need send special Authentication frame, you can do it in your user component in afterLogin event

After that, this user can receive events only for him. See example below, send event only for single (concrete) $user

and your javascript

Client scripts registration

Event frame

Set up shared data

You can set expiration using setLifeTime(integer $lifetime) method of class PublicData

Room events

Only member of testRoom can catch this event

Invoke client function or method

In your PHP application you can invoke javascript function or method of object in window context.

Extends from Event frame => you can send it into specific room

DOM manipulations with jquery

Task: you need update price on client side after price update in each product

Send more than one frame per a time

Example 1:

Example 2:

PS

Sorry for my english :)


All versions of yii2-node-socket with dependencies

PHP Build Version
Package Version
Requires oncesk/elephant.io 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 ratacibernetica/yii2-node-socket contains the following files

Loading the files please wait ....