oncesk / yii-node-socket

66 stars 46 forks source link

Yii 2 #24

Closed farmani closed 9 years ago

farmani commented 10 years ago

the idea behind this ext is great I think if you have any idea to port it for yii 2? you can count on me if you need any help.

oncesk commented 10 years ago

Hi, thank you, i want create standalone library and implement as extension or bundle for frameworks...

Repository already exists, php-node-socket, develop branch, but some things will be changed

BambangSinaga commented 9 years ago

hi, has this extension integrate with yii2? I have problem when start server. if I execute "yii" command on console, it seems list node-socket command also.

To see the help of each command, enter:

yii help

but, when I execute "yii node-socket" command in console, its thrown error with message C:\xampp\htdocs\ned_web>yii node-socket Error: Unknown command "node-socket".

would you like to help me?

oncesk commented 9 years ago

hi, yes extension is integrated with Yii2

try to use

$> yii node-socket/start
BambangSinaga commented 9 years ago

I do.. but thrown this error C:\xampp\htdocs\ned_web>yii node-socket/start Exception 'yii\base\UnknownMethodException' with message 'Calling unknown method : YiiNodeSocket\NodeSocketCommand::usageError()'

in C:\xampp\htdocs\ned_web\vendor\yiisoft\yii2\base\Component.php:285

Stack trace:

0 C:\xampp\htdocs\ned_web\vendor\oncesk\yii-node-socket\lib\php\NodeSocketComma

nd.php(149): yii\base\Component->__call('usageError', Array)

1 C:\xampp\htdocs\ned_web\vendor\oncesk\yii-node-socket\lib\php\NodeSocketComma

nd.php(149): YiiNodeSocket\NodeSocketCommand->usageError('Please provide ...')

2 C:\xampp\htdocs\ned_web\vendor\oncesk\yii-node-socket\lib\php\NodeSocketComma

nd.php(188): YiiNodeSocket\NodeSocketCommand->getComponent()

3 C:\xampp\htdocs\ned_web\vendor\oncesk\yii-node-socket\lib\php\NodeSocketComma

nd.php(178): YiiNodeSocket\NodeSocketCommand->getPidFile()

4 C:\xampp\htdocs\ned_web\vendor\oncesk\yii-node-socket\lib\php\NodeSocketComma

nd.php(168): YiiNodeSocket\NodeSocketCommand->updatePid()

5 C:\xampp\htdocs\ned_web\vendor\oncesk\yii-node-socket\lib\php\NodeSocketComma

nd.php(215): YiiNodeSocket\NodeSocketCommand->getPid()

6 C:\xampp\htdocs\ned_web\vendor\oncesk\yii-node-socket\lib\php\NodeSocketComma

nd.php(36): YiiNodeSocket\NodeSocketCommand->_start()

7 [internal function]: YiiNodeSocket\NodeSocketCommand->actionStart()

8 C:\xampp\htdocs\ned_web\vendor\yiisoft\yii2\base\InlineAction.php(55): call_u

ser_func_array(Array, Array)

9 C:\xampp\htdocs\ned_web\vendor\yiisoft\yii2\base\Controller.php(151): yii\bas

e\InlineAction->runWithParams(Array)

10 C:\xampp\htdocs\ned_web\vendor\yiisoft\yii2\console\Controller.php(91): yii\

base\Controller->runAction('start', Array)

11 C:\xampp\htdocs\ned_web\vendor\yiisoft\yii2\base\Module.php(455): yii\consol

e\Controller->runAction('start', Array)

12 C:\xampp\htdocs\ned_web\vendor\yiisoft\yii2\console\Application.php(161): yi

i\base\Module->runAction('node-socket/sta...', Array)

13 C:\xampp\htdocs\ned_web\vendor\yiisoft\yii2\console\Application.php(137): yi

i\console\Application->runAction('node-socket/sta...', Array)

14 C:\xampp\htdocs\ned_web\vendor\yiisoft\yii2\base\Application.php(375): yii\c

onsole\Application->handleRequest(Object(yii\console\Request))

15 C:\xampp\htdocs\ned_web\yii(31): yii\base\Application->run()

16 {main}

C:\xampp\htdocs\ned_web>

BambangSinaga commented 9 years ago

I have search solution according to error, but nothing answer this problem

oncesk commented 9 years ago

do you add command to controllerMap in your console config like its described in configuration instructions?

can you show me you configuration?

BambangSinaga commented 9 years ago

yes,

This is my all console configuration

<?php
$params = array_merge(
    require(__DIR__ . '/../../common/config/params.php'),
    require(__DIR__ . '/../../common/config/params-local.php'),
    require(__DIR__ . '/params.php'),
    require(__DIR__ . '/params-local.php')
);

return [
    'id' => 'app-console',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'controllerNamespace' => 'console\controllers',
    'controllerMap' => [
        'node-socket' => '\YiiNodeSocket\NodeSocketCommand',
    ],
    'components' => [
        'log' => [
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
    ],
    'params' => $params,
];
BambangSinaga commented 9 years ago

is there any wrong with my console configuration?

oncesk commented 9 years ago

one moment please i fix it now

BambangSinaga commented 9 years ago

okay, tks before..

oncesk commented 9 years ago

you need to add nodeSocket component configuration to your config files

BambangSinaga commented 9 years ago

yes i have copy this config

    'nodeSocket' => [
        'class' => '\YiiNodeSocket\NodeSocket',
        'dbOptions' => '',
        'host' => 'localhost',
        'allowedServerAddresses' => [
            "localhost",
            "127.0.0.1"
        ],
        'origin' => '*:*',
        'sessionVarName' => 'PHPSESSID',
        'port' => 3001,
        'socketLogFile' => '/var/log/node-socket.log',
    ],

to common/config in component section, and add aliases too, but still get same error

oncesk commented 9 years ago

setup extension in your composer to 2.0.4 version and update it

oncesk commented 9 years ago

with 'dbOptions' => '' will be error, i already removed it from documentation

oncesk commented 9 years ago

please notify me when check it

BambangSinaga commented 9 years ago

ok, sure..

BambangSinaga commented 9 years ago

when I run "composer update", this happen C:\xampp\htdocs\ned_web>composer update Loading composer repositories with package information Updating dependencies (including require-dev)

update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no- progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [packages1] ... [p ackagesN]

and when run "yii node-socket/start", thrown error bellow: C:\xampp\htdocs\ned_web>yii node-socket/start Exception 'ReflectionException' with message 'Class \YiiNodeSocket\NodeSocketCom mand does not exist'

in C:\xampp\htdocs\ned_web\vendor\yiisoft\yii2\di\Container.php:415

Stack trace:

0 C:\xampp\htdocs\ned_web\vendor\yiisoft\yii2\di\Container.php(415): Reflection

Class->__construct('\YiiNodeSocket...')

1 C:\xampp\htdocs\ned_web\vendor\yiisoft\yii2\di\Container.php(358): yii\di\Con

tainer->getDependencies('\YiiNodeSocket...')

2 C:\xampp\htdocs\ned_web\vendor\yiisoft\yii2\di\Container.php(151): yii\di\Con

tainer->build('\YiiNodeSocket...', Array, Array)

3 C:\xampp\htdocs\ned_web\vendor\yiisoft\yii2\BaseYii.php(340): yii\di\Containe

r->get('\YiiNodeSocket...', Array)

4 C:\xampp\htdocs\ned_web\vendor\yiisoft\yii2\base\Module.php(508): yii\BaseYii

::createObject('\YiiNodeSocket...', Array)

5 C:\xampp\htdocs\ned_web\vendor\yiisoft\yii2\base\Module.php(449): yii\base\Mo

dule->createController('node-socket/sta...')

6 C:\xampp\htdocs\ned_web\vendor\yiisoft\yii2\console\Application.php(161): yii

\base\Module->runAction('node-socket/sta...', Array)

7 C:\xampp\htdocs\ned_web\vendor\yiisoft\yii2\console\Application.php(137): yii

\console\Application->runAction('node-socket/sta...', Array)

8 C:\xampp\htdocs\ned_web\vendor\yiisoft\yii2\base\Application.php(375): yii\co

nsole\Application->handleRequest(Object(yii\console\Request))

9 C:\xampp\htdocs\ned_web\yii(31): yii\base\Application->run()

10 {main}

oncesk commented 9 years ago

seems like composer does not install new version, seems like problem with directory permissions

BambangSinaga commented 9 years ago

I have successfull reinstall node-socket capture

and configure my config according to documentation. But when I start, thrown error like below capture2

I also have warning when run "npm install command" capture4

and error in this section capture3

oncesk commented 9 years ago

hi, you need to check your configuration nodeSocket component should be in component section, yesterday i setup it from scratch and all works

error throws on 152 line of NodeSocketCommand file you can check it manually, check if component exists in yii service locator

just now i checked npm install command and all components was installed succesfully i have v0.10.36 and v0.12.6 versions of nodejs

for fixing npm install you can try to remove mongoose lib from package.json which located in lib/js/server/package.json or install python)

before that you can fork extension to your github account

seems like all of that problems because you os is windows :)

BambangSinaga commented 9 years ago

I finally successfull start the server capture5 I move nodeSocket component to common config, which before I write it in frontend config. Next, I add this config to common config also capture6 and start again server, but it says "No Instance(s) Available." capture7 what should I do? and actually, what this config used for?

oncesk commented 9 years ago

do you setup all nodejs dependencies?

do you saw nodejs logs which should locates in runtime folder if you are not redefine socketLogFile property? try to start server manually in folder lib/js/server using this command for log output into console

$> node server.js

and watch, maybe port already in use

oncesk commented 9 years ago

i have not ability to check it on windows system)

BambangSinaga commented 9 years ago

server start properly capture8

and it seems log file not created, eventhough I search "node-socket.log" in my yii2 project. I have configure nodeSocket component log like this 'socketLogFile' => '/var/log/node-socket.log',

oncesk commented 9 years ago

seems like all is good)