<?php
namespace mylibs/name;
use Yii;
class Myclass
{
// Реализация класса
}
use app mylibs\name\Myclass;
$cl = new Myclass();
<?php
namespace app\commands;
use yii\console\Controller;
use Workerman\Worker;
class ServerController extends Controller
{
public function actionStart($port = 27015)
{
// Autoloader::loadByNamespace('Workerman');
$ws_worker = new Worker('websocket://127.0.0.1:2346');
// 4 processes
$ws_worker->count = 4;
// Emitted when new connection come
$ws_worker->onConnect = function ($connection) {
echo "New connection\n";
};
// Emitted when data received
$ws_worker->onMessage = function ($connection, $data) {
// Send hello $data
$connection->send('Hello ' . $data);
};
// Emitted when connection closed
$ws_worker->onClose = function ($connection) {
echo "Connection closed\n";
};
// Run worker
Worker::runAll();
}
}
Fatal error: Declaration of Workerman\Events\React\Base::cancelTimer(React\EventLoop\TimerInterface $timer) must be compatible with React\EventLoop\LoopInterface::cancelTimer(React\EventLoop\Timer\TimerInterface $timer) in W:\domains\crypter-chat\vendor\workerman\workerman\Events\React\Base.php on line 24
PHP Compile Error 'yii\base\ErrorException' with message 'Declaration of Workerman\Events\React\Base::cancelTimer(React\EventLoop\TimerInterface $timer) must be compatible with React\EventLoop\LoopInterface::cancelTimer(React\EventLoop\Timer\TimerInterface $timer)'
in W:\domains\crypter-chat\vendor\workerman\workerman\Events\React\Base.php:24
Stack trace:
#0 W:\domains\crypter-chat\vendor\yiisoft\yii2\base\ErrorHandler.php(0): yii\console\ErrorHandler->handleFatalError()
#1 W:\domains\crypter-chat\vendor\composer\ClassLoader.php(444): ::unknown()
#2 W:\domains\crypter-chat\vendor\composer\ClassLoader.php(322): ::Composer\Autoload\includeFile()
#3 W:\domains\crypter-chat\vendor\workerman\workerman\Events\React\StreamSelectLoop.php(20): Composer\Autoload\ClassLoader->loadClass()
#4 W:\domains\crypter-chat\vendor\workerman\workerman\Events\React\StreamSelectLoop.php(20): ::spl_autoload_call()
#5 W:\domains\crypter-chat\vendor\composer\ClassLoader.php(444): ::unknown()
#6 W:\domains\crypter-chat\vendor\composer\ClassLoader.php(322): ::Composer\Autoload\includeFile()
#7 W:\domains\crypter-chat\vendor\workerman\workerman\Worker.php(2373): Composer\Autoload\ClassLoader->loadClass()
#8 W:\domains\crypter-chat\vendor\workerman\workerman\Worker.php(2373): ::spl_autoload_call()
#9 W:\domains\crypter-chat\vendor\workerman\workerman\Worker.php(1404): Workerman\Worker->run()
#10 W:\domains\crypter-chat\vendor\workerman\workerman\Worker.php(1347): Workerman\Worker::forkWorkersForWindows()
#11 W:\domains\crypter-chat\vendor\workerman\workerman\Worker.php(546): Workerman\Worker::forkWorkers()
#12 W:\domains\crypter-chat\commands\ServerController.php(38): Workerman\Worker::runAll()
#13 W:\domains\crypter-chat\vendor\yiisoft\yii2\base\InlineAction.php(57): app\commands\ServerController->actionStart()
#14 W:\domains\crypter-chat\vendor\yiisoft\yii2\base\InlineAction.php(57): ::call_user_func_array:{W:\domains\crypter-chat\vendor\yiisoft\yii2\base\InlineAction.php:57}()
#15 W:\domains\crypter-chat\vendor\yiisoft\yii2\base\Controller.php(180): yii\base\InlineAction->runWithParams()
#16 W:\domains\crypter-chat\vendor\yiisoft\yii2\console\Controller.php(181): app\commands\ServerController->runAction()
#17 W:\domains\crypter-chat\vendor\yiisoft\yii2\base\Module.php(528): app\commands\ServerController->runAction()
#18 W:\domains\crypter-chat\vendor\yiisoft\yii2\console\Application.php(180): yii\console\Application->runAction()
#19 W:\domains\crypter-chat\vendor\yiisoft\yii2\console\Application.php(147): yii\console\Application->runAction()
#20 W:\domains\crypter-chat\vendor\yiisoft\yii2\base\Application.php(386): yii\console\Application->handleRequest()
#21 W:\domains\crypter-chat\yii(20): yii\console\Application->run()
#22 {main}