Closed farmani closed 9 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
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?
hi, yes extension is integrated with Yii2
try to use
$> yii node-socket/start
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:
nd.php(149): yii\base\Component->__call('usageError', Array)
nd.php(149): YiiNodeSocket\NodeSocketCommand->usageError('Please provide ...')
nd.php(188): YiiNodeSocket\NodeSocketCommand->getComponent()
nd.php(178): YiiNodeSocket\NodeSocketCommand->getPidFile()
nd.php(168): YiiNodeSocket\NodeSocketCommand->updatePid()
nd.php(215): YiiNodeSocket\NodeSocketCommand->getPid()
nd.php(36): YiiNodeSocket\NodeSocketCommand->_start()
ser_func_array(Array, Array)
e\InlineAction->runWithParams(Array)
base\Controller->runAction('start', Array)
e\Controller->runAction('start', Array)
i\base\Module->runAction('node-socket/sta...', Array)
i\console\Application->runAction('node-socket/sta...', Array)
onsole\Application->handleRequest(Object(yii\console\Request))
C:\xampp\htdocs\ned_web>
I have search solution according to error, but nothing answer this problem
do you add command to controllerMap in your console config like its described in configuration instructions?
can you show me you configuration?
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,
];
is there any wrong with my console configuration?
one moment please i fix it now
okay, tks before..
you need to add nodeSocket component configuration to your config files
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
setup extension in your composer to 2.0.4 version and update it
with 'dbOptions' => '' will be error, i already removed it from documentation
please notify me when check it
ok, sure..
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)
Removing oncesk/yii-node-socket (2.0.3)
[UnexpectedValueException] RecursiveDirectoryIterator::__construct(C:\xampp\htdocs\ned_web\vendor/once sk/yii-node-socket\examples\events,C:\xampp\htdocs\ned_web\vendor/oncesk/yi i-node-socket\examples\events): Access is denied. (code: 5)
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:
Class->__construct('\YiiNodeSocket...')
tainer->getDependencies('\YiiNodeSocket...')
tainer->build('\YiiNodeSocket...', Array, Array)
r->get('\YiiNodeSocket...', Array)
::createObject('\YiiNodeSocket...', Array)
dule->createController('node-socket/sta...')
\base\Module->runAction('node-socket/sta...', Array)
\console\Application->runAction('node-socket/sta...', Array)
nsole\Application->handleRequest(Object(yii\console\Request))
seems like composer does not install new version, seems like problem with directory permissions
I have successfull reinstall node-socket
and configure my config according to documentation. But when I start, thrown error like below
I also have warning when run "npm install command"
and error in this section
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 :)
I finally successfull start the server I move nodeSocket component to common config, which before I write it in frontend config. Next, I add this config to common config also and start again server, but it says "No Instance(s) Available." what should I do? and actually, what this config used for?
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
i have not ability to check it on windows system)
server start properly
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',
seems like all is good)
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.