2017 © Pedro PelΓ‘ez
 

yii2-extension yii2multiresponse

Multiresponse component

image

larsnovikov/yii2multiresponse

Multiresponse component

  • Wednesday, June 20, 2018
  • by larsnovikov
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 60 % Grown

The README.md

Multiresponse for Yii2

ΠšΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ‚ для Π΄ΠΎΠ·Π°Π³Ρ€ΡƒΠ·ΠΊΠΈ ΠΊΠΎΠ½Ρ‚Π΅Π½Ρ‚Π° Ρ‡Π΅Ρ€Π΅Π· websocket. УскоряСт отрисовку Π²ΠΈΠ΄ΠΆΠ΅Ρ‚ΠΎΠ² микросСрвисов Π΄ΠΎ 50% ΠΏΡƒΡ‚Π΅ΠΌ распараллСливания ΠΎΠ±Ρ€Π°Ρ‰Π΅Π½ΠΈΠΉ ΠΊ API. Π’Π°ΠΊ ΠΆΠ΅ ΠΌΠΎΠΆΠ½ΠΎ Ρ€Π°ΡΠΏΠ°Ρ€Π°Π»Π»Π΅Π»ΠΈΡ‚ΡŒ ΠΈ ΠΎΠ±Ρ€Π°Π±ΠΎΡ‚ΠΊΡƒ рСсурсоСмких Π·Π°Π΄Π°Ρ‡., (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

composer require larsnovikov/yii2multiresponse

or add, (*4)

"larsnovikov/yii2multiresponse": "*"

to the require section of your composer.json file., (*5)

Usage

  1. Π”ΠΎΠ±Π°Π²ΡŒ Π² ΠΊΠΎΠ½Ρ„ΠΈΠ³Π΅ Π² modules:
'yii2multiresponse' => [
    'class' => 'vendor\larsnovikov\yii2multiresponse\Module',
    'socketUrls' => [
        // TODO Ρ‚ΡƒΡ‚ Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ ΡΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ ΠΏΡƒΡ‚ΠΈ для Π²ΠΈΠ΄ΠΆΠ΅Ρ‚ΠΎΠ² ΠΊ WebSocket сСрвСру
        \vendor\larsnovikov\yii2multiresponse\examples\widgets\HtmlTestWidget::class => [
            'ws://socket-test.loc:5005',
            'ws://socket-test.loc:5006', 
            'ws://socket-test.loc:5007'
        ],
        \vendor\larsnovikov\yii2multiresponse\examples\widgets\JsonTestWidget::class => [
            'ws://socket-test.loc:5005',
            'ws://socket-test.loc:5006',
            'ws://socket-test.loc:5007'
        ]
    ]
],
  1. Π”ΠΎΠ±Π°Π²ΡŒ Π² ΠΊΠΎΠ½Ρ„ΠΈΠ³Π΅ Π² components ΠΎΡ‡Π΅Ρ€Π΅Π΄ΡŒ:
'multiResponseQueue' => array_merge(
    [
        'class' => \yii\queue\amqp_interop\Queue::class,
        'queueName' => 'multiresponse.queue'
    ],
    [
        'port' => 5672,
        'user' => 'public',
        'password' => 'public',
        'driver' => yii\queue\amqp_interop\Queue::ENQUEUE_AMQP_LIB,
        'dsn' => 'amqp://public:public@172.17.0.1:5672/%2F',
    ]
),
  1. Π”ΠΎΠ±Π°Π²ΡŒ Π² ΠΊΠΎΠ½Ρ„ΠΈΠ³Π΅ Π² bootstrap Π½Π°Π·Π²Π°Π½ΠΈΠ΅ ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ‚Π° ΠΎΡ‡Π΅Ρ€Π΅Π΄ΠΈ, (*6)

  2. УнаслСдуй свой Π²ΠΈΠ΄ΠΆΠ΅Ρ‚ ΠΎΡ‚ vendor\larsnovikov\yii2multiresponse\widgets\AbstractHtmlWidget ΠΈΠ»ΠΈ vendor\larsnovikov\yii2multiresponse\widgets\AbstractJsonWidget Π² зависимости ΠΎΡ‚ Ρ‚ΠΎΠ³ΠΎ ΠΊΠ°ΠΊΠΎΠΉ ΠΎΡ‚Π²Π΅Ρ‚ ΠΎΡ‚ WS-сСрвСра Π½Π°Π΄ΠΎ ΠΏΠΎΠ»ΡƒΡ‡ΠΈΡ‚ΡŒ, (*7)

  3. Π’Ρ‹Π²Π΅Π΄ΠΈ Π²ΠΈΠ΄ΠΆΠ΅Ρ‚, Π½Π°ΠΏΡ€ΠΈΠΌΠ΅Ρ€:, (*8)

echo \vendor\larsnovikov\yii2multiresponse\examples\widgets\HtmlTestWidget::widget([
        'dataRequest' => new \vendor\larsnovikov\yii2multiresponse\requests\DataRequest(
                             '@vendor/larsnovikov/yii2multiresponse/widgets/views/empty_container',
                             \vendor\larsnovikov\yii2multiresponse\examples\widgets\HtmlTestWidget::class,
                             [
                                 'test1' => rand(0, 9999),
                                 'test2' => rand(0, 9999)
                             ])
        ]);

Запуск

  1. Запусти WSServer php yii yii2multiresponse/server/start <port> ΠΈΠ»ΠΈ bash socket.sh <port>, Π³Π΄Π΅ <port> - Π½ΠΎΠΌΠ΅Ρ€ ΠΏΠΎΡ€Ρ‚Π°
  2. Запусти ΡΠ»ΡƒΡˆΠ°Ρ‚Π΅Π»Π΅ΠΉ ΠΎΡ‡Π΅Ρ€Π΅Π΄Π΅ΠΉ, Π½Π°ΠΏΡ€ΠΈΠΌΠ΅Ρ€: php yii multi-response-queue/listen

The Versions

20/06 2018

dev-master

9999999-dev

Multiresponse component

  Sources   Download

MIT

The Requires

 

by Avatar larsnovikov

extension yii2

19/06 2018
17/06 2018
14/06 2018