workerman 兼容linux和windows的方法


咱们都是来实际的,直接上代码



/**
* 这个文件自动识别win和linux平台
* 使用方式: 把vendor/autoload.php 导入的代码换成此文件,并修改相关的路径
*
* Licensed under The MIT License
* For full copyright and license information, please see the MIT-LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @author Hawind<hawind@qq.com>
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/

if (DIRECTORY_SEPARATOR === '/') {
// linux:
$workermanDir = '/workerman';
$gatewayDir = '/gateway-worker/src';
} else {
// windows:
$workermanDir = '/workerman-for-win';
$gatewayDir = '/gateway-worker-for-win/src';
}

$vendorDir = __DIR__ . '/vendor';

// 自动加载类
$loader = require_once $vendorDir . '/autoload.php';

// 重新设置 Workerman 相关路径
$loader->setPsr4('Workerman\\', $vendorDir. '/workerman'. $workermanDir);
$loader->setPsr4('GatewayWorker\\', $vendorDir .'/workerman'. $gatewayDir);

声明:大家学-卢卫湘|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - workerman 兼容linux和windows的方法


加vx: beyonds 备注:app上架 lwxshow