PHP Fatal error: Uncaught Error: Class 'GatewayWorker\BusinessWorker' not found

bluelight2003

PHP Fatal error:  Uncaught Error: Class 'GatewayWorker\BusinessWorker' not found in /var/www/html/Applications/temp/start_businessworker.php:16
Stack trace:

0 /var/www/html/start.php(34): require_once()

1 {main}

  thrown in /var/www/html/Applications/temp/start_businessworker.php on line 16

7244 5 0
5个回答

phpcreeper

启动文件没有正确的 use \GatewayWorker\BusinessWorker;  吗?

  • bluelight2003 2019-04-17

    use \Workerman\Worker;
    use \GatewayWorker\BusinessWorker;
    use \Workerman\Autoloader;
    require_once __DIR__.'/../../vendor/Workerman/Autoloader.php';

    // bussinessWorker 进程
    $worker = new BusinessWorker();

  • bluelight2003 2019-04-17

    start_businessworker.php

  • tangzq 2019-04-18

    有没有引入自动加载文件? autoload那个

bluelight2003

use \Workerman\Worker;
use \GatewayWorker\BusinessWorker;
use \Workerman\Autoloader;
require_once __DIR__.'/../../vendor/Workerman/Autoloader.php';

// bussinessWorker 进程
$worker = new BusinessWorker();

  • 暂无评论
phpcreeper

不是  require_once __DIR__.'/../../vendor/Workerman/Autoloader.php';
而是
require_once ‘/path/to/vendor/autoload.php';

  • 暂无评论
bluelight2003

非常感谢您的指导   随后对路径详细了解了一下    最后把文件的整体目录结构调整了一下  
Workerman start in DEBUG mode
------------------------------- WORKERMAN --------------------------------
Workerman version:3.5.19          PHP version:7.0.33-0ubuntu0.16.04.1
-------------------------------- WORKERS ---------------------------------
proto   user            worker          listen          processes    status
Press Ctrl+C to stop. Start success.
 

  • 暂无评论
cloudty

我来插一句.  也有可能是因为  需要 通过 composer require workerman/gateway-worker  安装组件
我是直接复制的demo文件.结果就是出现这个..Class 'GatewayWorker\BusinessWorker' not found
折腾了好久..最后在README.md文件里面看到用 composer安装..  接着 就成功了....
官方文档就不能给个安装示例么.....
 

  • yongdao35 2019-08-31

    每个项目的readme就是文档啊,自己不看怪别人?

年代过于久远,无法发表回答
×
🔝