初始化代码

This commit is contained in:
2025-12-22 14:33:31 +08:00
parent d02b31a8b9
commit c2c5ae2fdd
2313 changed files with 467239 additions and 0 deletions

72
config/app.php Normal file
View File

@@ -0,0 +1,72 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// +----------------------------------------------------------------------
// | 应用设置
// +----------------------------------------------------------------------
use think\facade\Env;
use think\facade\Request;
//By.jingshuixian
//自定义开发模式
$adminModelListPaht = include app()->getBasePath().'/Info.php';
if(Env::get('DEV_MODE',false)){
$host = Request::host();
$infoPath = app()->getBasePath().'/Info_'.$host.'.php';
if(file_exists($infoPath)){
$infoData = include $infoPath;
$adminModelListPaht = $infoData ;
}
}
return [
// 应用地址
'app_host' => Env::get('app.host', ''),
// 应用Trace环境变量优先读取
'app_trace' => false,
// 应用的命名空间
'app_namespace' => '',
// 是否启用路由
'with_route' => true,
// 是否启用事件
'with_event' => true,
// 自动多应用模式
'auto_multi_app' => true,
// 应用映射(自动多应用模式有效)
'app_map' => [],
// 域名绑定(自动多应用模式有效)
'domain_bind' => [],
// 禁止URL访问的应用列表自动多应用模式有效
'deny_app_list' => [],
// 默认应用
'default_app' => 'index',
// 默认时区
'default_timezone' => 'Asia/Shanghai',
// 默认验证器
'default_validate' => '',
// 异常页面的模板文件
'exception_tmpl' => app()->getThinkPath() . 'tpl/think_exception.tpl',
// 错误显示信息,非调试模式有效
'error_message' => '页面错误!请稍后再试~',
// 显示错误信息
'show_error_msg' => true,
//是否是微擎系统
//'is_weiqin' => true,
//By.jingshuixian 2019年11月23日16:13:36
'AdminModelList' => $adminModelListPaht,
//验证地址 // 这里应该是多个验证地址,防止验证失败
'longbing_saas_url'=> 'http://api.longbing.org',
'longbing_version' => '0.0.1',
];

77
config/cache.php Normal file
View File

@@ -0,0 +1,77 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\facade\Env;
defined('IN_IA') || define('IN_IA',true);
// +----------------------------------------------------------------------
// | 缓存设置
// +----------------------------------------------------------------------
$host = Env::get('cache.host', '127.0.0.1');
$prefix = Env::get('cache.prefix', 'longbing_');
$password = Env::get('cache.passwd', '');
$expire = Env::get('cache.expire', 0);
$port = Env::get('cache.port', 6379);
$dir_path = __DIR__ . '/../../../../data/config.php';
// var_dump(file_exists($dir_path));
if(file_exists($dir_path) && longbingIsWeiqin())
{
require_once $dir_path;
if(isset($config['setting']['redis']['server']) ) $host = $config['setting']['redis']['server'];
if(isset($config['setting']['redis']['prefix']) ) $prefix = $config['setting']['redis']['prefix'];
if(isset($config['setting']['redis']['pconnect']) ) $expire = $config['setting']['redis']['pconnect'];
if(isset($config['setting']['redis']['requirepass']) ) $password = $config['setting']['redis']['requirepass'];
if(isset($config['setting']['redis']['port']) ) $port = $config['setting']['redis']['port'];
}
// var_dump($host ,$prefix ,$password ,$expire);die;
return [
// 默认缓存驱动
'default' => Env::get('cache.driver', 'redis'),
// 缓存连接方式配置
'stores' => [
// 'file' => [
// // 驱动方式
// 'type' => 'file',
// // 缓存保存目录
// 'path' => '',
// // 缓存前缀
// 'prefix' => '',
// // 缓存有效期 0表示永久缓存
// 'expire' => 0,
// // 缓存标签前缀
// 'tag_prefix' => 'tag:',
// // 序列化机制 例如 ['serialize', 'unserialize']
// 'serialize' => [],
// ],
// 更多的缓存连接
// redis缓存
'redis' => [
// 驱动方式
'type' => 'redis',
// 服务器地址
'host' => !empty($host)?$host:'127.0.0.1',
//前缀
'prefix' => !empty($prefix)?$prefix:'longbing_',
//密码
'password' => $password,
//有效时长
'expire' => $expire,
//端口
'port' => !empty($port)?$port:'6379'
],
],
];

28
config/console.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// +----------------------------------------------------------------------
// | 控制台配置
// +----------------------------------------------------------------------
//return [
// // 执行用户Windows下无效
// 'user' => null,
// // 指令定义
// 'commands' => [
//
// ],
//];
return [
'commands' => [
'Swoole-Im' => 'app\command\SwooleIm',
]
];

28
config/cookie.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// +----------------------------------------------------------------------
// | Cookie设置
// +----------------------------------------------------------------------
return [
// cookie 保存时间
'expire' => 0,
// cookie 保存路径
'path' => '/',
// cookie 有效域名
'domain' => '',
// cookie 启用安全传输
'secure' => false,
// httponly设置
'httponly' => false,
// 是否使用 setcookie
'setcookie' => true,
];

91
config/database.php Normal file
View File

@@ -0,0 +1,91 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\facade\Env;
defined('IN_IA') || define('IN_IA',true);
$dir_path = __DIR__ . '/../../../../data/config.php';
if(file_exists($dir_path) && longbingIsWeiqin())
{
require $dir_path;
}else{
$config = array();
$config['db']['master']['host'] = Env::get('database.hostname', '127.0.0.1');
$config['db']['master']['username'] = Env::get('database.username', 'root');
$config['db']['master']['password'] = Env::get('database.password', '');
$config['db']['master']['port'] = Env::get('database.hostport', '3306');
$config['db']['master']['database'] = Env::get('database.database', '');
$config['db']['master']['charset'] = Env::get('database.charset', 'utf8mb4');
$config['db']['master']['pconnect'] = 0;
$config['db']['master']['tablepre'] = Env::get('database.prefix', 'ims');
}
return [
// 默认使用的数据库连接配置
'default' => Env::get('database.driver', 'mysql'),
// 数据库连接配置信息
'connections' => [
'mysql' => [
// 数据库类型
'type' => 'mysql',
// 服务器地址
'hostname' => $config['db']['master']['host'],
// 数据库名
'database' => $config['db']['master']['database'],
// 用户名
'username' => $config['db']['master']['username'] ,
// 密码
'password' => $config['db']['master']['password'],
// 端口
'hostport' => $config['db']['master']['port'],
// 连接dsn
'dsn' => '',
// 数据库连接参数
'params' => [],
// 数据库编码默认采用utf8
'charset' => 'utf8mb4' ,
// 数据库表前缀
'prefix' => $config['db']['master']['tablepre'] ,
// 数据库调试模式
'debug' => Env::get('APP_DEBUG', false),
// 监听SQL
'trigger_sql' => Env::get('APP_DEBUG', false),
// 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
'deploy' => 0,
// 数据库读写是否分离 主从式有效
'rw_separate' => false,
// 读写分离后 主服务器数量
'master_num' => 1,
// 指定从服务器序号
'slave_no' => '',
// 是否严格检查字段是否存在
'fields_strict' => true,
// 是否需要进行SQL性能分析
'sql_explain' => false,
// Builder类
'builder' => '',
// Query类
'query' => '',
// 是否需要断线重连
'break_reconnect' => false,
//数据集返回类型
'resultset_type' => 'array',
],
// 更多的数据库配置信息
],
// 自定义时间查询规则
'time_query_rule' => [],
// 自动写入时间戳字段
// 'auto_timestamp' => 'timestamp',
'auto_timestamp' => true,
// 时间字段取出后的默认时间格式
// 'datetime_format' => 'Y-m-d H:i:s',
];

24
config/filesystem.php Normal file
View File

@@ -0,0 +1,24 @@
<?php
use think\facade\Env;
return [
'default' => Env::get('filesystem.driver', 'local'),
'disks' => [
'local' => [
'type' => 'local',
'root' => app()->getRuntimePath() . 'storage',
],
'public' => [
'type' => 'local',
'root' => app()->getRootPath() . 'public/storage',
'url' => '/storage',
'visibility' => 'public',
],
// 更多的磁盘配置信息
'longbing' => [
'type' => 'local',
'root' => FILE_UPLOAD_PATH,
]
],
];

45
config/gateway_worker.php Normal file
View File

@@ -0,0 +1,45 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// +----------------------------------------------------------------------
// | Workerman设置 仅对 php think worker:gateway 指令有效
// +----------------------------------------------------------------------
return [
// 扩展自身需要的配置
'protocol' => 'websocket', // 协议 支持 tcp udp unix http websocket text
'host' => '0.0.0.0', // 监听地址
'port' => 2348, // 监听端口
'socket' => '', // 完整监听地址
'context' => [], // socket 上下文选项
'register_deploy' => true, // 是否需要部署register
'businessWorker_deploy' => true, // 是否需要部署businessWorker
'gateway_deploy' => true, // 是否需要部署gateway
// Register配置
'registerAddress' => '127.0.0.1:1236',
// Gateway配置
'name' => 'thinkphp',
'count' => 1,
'lanIp' => '127.0.0.1',
'startPort' => 2000,
'daemonize' => false,
'pingInterval' => 30,
'pingNotResponseLimit' => 0,
'pingData' => '{"type":"ping"}',
// BusinsessWorker配置
'businessWorker' => [
'name' => 'BusinessWorker',
'count' => 1,
'eventHandler' => '\think\worker\Events',
],
];

37
config/lang.php Normal file
View File

@@ -0,0 +1,37 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// +----------------------------------------------------------------------
// | 多语言设置
// +----------------------------------------------------------------------
use think\facade\Env;
return [
// 默认语言
'default_lang' => Env::get('lang.default_lang', 'zh-cn'),
// 允许的语言列表
'allow_lang_list' => ['zh-cn', 'en-us'],
// 多语言自动侦测变量名
'detect_var' => 'lang',
// 是否使用Cookie记录
'use_cookie' => true,
// 多语言cookie变量
'cookie_var' => 'think_lang',
// 扩展语言包
'extend_list' => [],
// Accept-Language转义为对应语言包名称
'accept_language' => [
'zh-hans-cn' => 'zh-cn',
],
// 是否支持语言分组
'allow_group' => true,
];

55
config/log.php Normal file
View File

@@ -0,0 +1,55 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\facade\Env;
// +----------------------------------------------------------------------
// | 日志设置
// +----------------------------------------------------------------------
return [
// 默认日志记录通道
'default' => Env::get('log.channel', 'file') ,
// 日志记录级别
'level' => [],
// 日志类型记录的通道 ['error'=>'email',...]
'type_channel' => [],
// 是否关闭日志写入
'close' => Env::get('APP_DEBUG', false) ,
// 日志通道列表
'channels' => [
'file' => [
// 日志记录方式
'type' => 'File',
// 日志保存目录
'path' => '',
// 单文件日志写入
'single' => true,
// 独立日志级别
'apart_level' => [],
// 最大日志文件数量
'max_files' => 100,
//文件大小
'file_size' => 1024,
],
// 其它日志通道配置
'SocketLog'=> [
'type' => 'SocketLog',
'host' => 'slog.migugu.com',
//日志强制记录到配置的client_id
'force_client_ids' => ['shuixian_zfH5NbLn','longbing_TkbB7uznHAdfLtCP','chenniang_qkEAbc1vgmKlL6H0'],
//限制允许读取日志的client_id
'allow_client_ids' => ['shuixian_zfH5NbLn','longbing_TkbB7uznHAdfLtCP','chenniang_qkEAbc1vgmKlL6H0'],
]
],
];

33
config/permissions.php Normal file
View File

@@ -0,0 +1,33 @@
<?php
// +----------------------------------------------------------------------
// | Longbing [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright Chengdu longbing Technology Co., Ltd.
// +----------------------------------------------------------------------
// | Website http://longbing.org/
// +----------------------------------------------------------------------
// | Author: ArtizanZhang
// | DataTime: 2019/12/9 9:46
// +----------------------------------------------------------------------
declare(strict_types=1);
use app\appstore\info\PermissionActivity;
use app\appstore\info\PermissionAppiont;
use app\appstore\info\PermissionArticle;
use app\appstore\info\Permission;
use app\appstore\info\PermissionPayqr;
use app\appstore\info\PermissionPoster;
use app\appstore\info\PermissionSend;
return [
//appstore
PermissionSend::class, //群发短信
PermissionActivity::class,
PermissionAppiont::class,
PermissionArticle::class,
Permission::class,
PermissionPayqr::class,
PermissionPoster::class,
];

79
config/route.php Normal file
View File

@@ -0,0 +1,79 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// +----------------------------------------------------------------------
// | 应用设置
// +----------------------------------------------------------------------
return [
// PATHINFO变量名 用于兼容模式
'var_pathinfo' => 's',
// 兼容PATH_INFO获取
'pathinfo_fetch' => ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL'],
// pathinfo分隔符
'pathinfo_depr' => '/',
// HTTPS代理标识
'https_agent_name' => '',
// URL伪静态后缀
'url_html_suffix' => 'html',
// URL普通方式参数 用于自动生成
'url_common_param' => true,
// 是否开启路由延迟解析
'url_lazy_route' => false,
// 是否强制使用路由
'url_route_must' => true,
// 合并路由规则
'route_rule_merge' => true,
// 路由是否完全匹配
'route_complete_match' => true,
// 使用注解路由
'route_annotation' => false,
// 是否开启路由缓存
'route_check_cache' => false,
// 路由缓存连接参数
'route_cache_option' => [],
// 路由缓存Key
'route_check_cache_key' => '',
// 访问控制器层名称
'controller_layer' => 'controller',
// 空控制器名
'empty_controller' => 'Error',
// 是否使用控制器后缀
'controller_suffix' => false,
// 默认的路由变量规则
'default_route_pattern' => '[\w\.]+',
// 域名根如thinkphp.cn
'url_domain_root' => '',
// 是否自动转换URL中的控制器和操作名
'url_convert' => true,
// 表单请求类型伪装变量
'var_method' => '_method',
// 表单ajax伪装变量
'var_ajax' => '_ajax',
// 表单pjax伪装变量
'var_pjax' => '_pjax',
// 是否开启请求缓存 true自动缓存 支持设置请求缓存规则
'request_cache' => false,
// 请求缓存有效期
'request_cache_expire' => null,
// 全局请求缓存排除规则
'request_cache_except' => [],
// 默认控制器名
'default_controller' => 'Index',
// 默认操作名
'default_action' => 'index',
// 操作方法后缀
'action_suffix' => '',
// 默认JSONP格式返回的处理方法
'default_jsonp_handler' => 'jsonpReturn',
// 默认JSONP处理方法
'var_jsonp_handler' => 'callback',
];

27
config/session.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// +----------------------------------------------------------------------
// | 会话设置
// +----------------------------------------------------------------------
return [
// session name
'name' => '',
// SESSION_ID的提交变量,解决flash上传跨域
'var_session_id' => '',
// 驱动方式 支持file redis memcache memcached
'type' => 'file',
// 过期时间
'expire' => 0,
// 前缀
'prefix' => '',
];

54
config/swoole.php Normal file
View File

@@ -0,0 +1,54 @@
<?php
use think\facade\Env;
use think\swoole\websocket\room\TableRoom;
use think\swoole\websocket\socketio\Handler;
use think\swoole\websocket\socketio\Parser;
return [
'server' => [
'host' => '0.0.0.0', // 监听地址
'port' => Env::get('swoole.port', '8005'), // 监听端口
'mode' => SWOOLE_PROCESS, // 运行模式 默认为SWOOLE_PROCESS
'sock_type' => SWOOLE_SOCK_TCP, // sock type 默认为SWOOLE_SOCK_TCP
'options' => [
'pid_file' => runtime_path() . 'swoole.pid',
'log_file' => Env::get('APP_DEBUG', false) ? runtime_path() . 'swoole.log' : false,
'daemonize' => Env::get('swoole.daemonize', false),
// Normally this value should be 1~4 times larger according to your cpu cores.
'reactor_num' => swoole_cpu_num(),
'worker_num' => swoole_cpu_num(),
'task_worker_num' => swoole_cpu_num(),
'enable_static_handler' => true,
'document_root' => root_path('public'),
'package_max_length' => 20 * 1024 * 1024,
'buffer_output_size' => 10 * 1024 * 1024,
'socket_buffer_size' => 128 * 1024 * 1024,
'max_request' => 3000,
'send_yield' => true,
],
],
'websocket' => [
'enabled' => true,
'handler' => Handler::class,
'parser' => Parser::class,
'route_file' => base_path() . 'im/controller/websocket.php',
'ping_interval' => 25000,
'ping_timeout' => 60000,
'room' => [
'type' => TableRoom::class,
'room_rows' => 4096,
'room_size' => 2048,
'client_rows' => 8192,
'client_size' => 2048,
],
],
'hot_update' => [
'enable' => true,
'name' => ['*.php'],
'include' => [app_path().'im/controller'],
'exclude' => [],
],
'auto_reload' => false,
'enable_coroutine' => true,
'resetters' => [],
'tables' => [],
];

25
config/template.php Normal file
View File

@@ -0,0 +1,25 @@
<?php
// +----------------------------------------------------------------------
// | 模板设置
// +----------------------------------------------------------------------
return [
// 模板引擎类型使用Think
'type' => 'Think',
// 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 3 保持操作方法
'auto_rule' => 1,
// 模板路径
'view_path' => '',
// 模板后缀
'view_suffix' => 'html',
// 模板文件名分隔符
'view_depr' => DIRECTORY_SEPARATOR,
// 模板引擎普通标签开始标记
'tpl_begin' => '{',
// 模板引擎普通标签结束标记
'tpl_end' => '}',
// 标签库标签开始标记
'taglib_begin' => '{',
// 标签库标签结束标记
'taglib_end' => '}',
];

18
config/trace.php Normal file
View File

@@ -0,0 +1,18 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// +----------------------------------------------------------------------
// | Trace设置 开启调试模式后有效
// +----------------------------------------------------------------------
return [
// 内置Html 支持扩展
'type' => 'Html',
];

23
config/view.php Normal file
View File

@@ -0,0 +1,23 @@
<?php
// +----------------------------------------------------------------------
// | 模板设置
// +----------------------------------------------------------------------
return [
// 模板引擎类型
'type' => 'Think',
// 模板路径
'view_path' => '',
// 模板后缀
'view_suffix' => 'html',
// 模板文件名分隔符
'view_depr' => '/',
// 模板引擎普通标签开始标记
'tpl_begin' => '{',
// 模板引擎普通标签结束标记
'tpl_end' => '}',
// 标签库标签开始标记
'taglib_begin' => '{',
// 标签库标签结束标记
'taglib_end' => '}',
];

30
config/worker.php Normal file
View File

@@ -0,0 +1,30 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// +----------------------------------------------------------------------
// | Workerman设置 仅对 php think worker 指令有效
// +----------------------------------------------------------------------
return [
// 扩展自身需要的配置
'host' => '0.0.0.0', // 监听地址
'port' => 2346, // 监听端口
'root' => '', // WEB 根目录 默认会定位public目录
'app_path' => '', // 应用目录 守护进程模式必须设置(绝对路径)
'file_monitor' => false, // 是否开启PHP文件更改监控调试模式下自动开启
'file_monitor_interval' => 2, // 文件监控检测时间间隔(秒)
'file_monitor_path' => [], // 文件监控目录 默认监控application和config目录
// 支持workerman的所有配置参数
'name' => 'thinkphp',
'count' => 4,
'daemonize' => false,
'pidFile' => '',
];

55
config/worker_server.php Normal file
View File

@@ -0,0 +1,55 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// +----------------------------------------------------------------------
// | Workerman设置 仅对 php think worker:server 指令有效
// +----------------------------------------------------------------------
return [
// 扩展自身需要的配置
'protocol' => 'websocket', // 协议 支持 tcp udp unix http websocket text
'host' => '0.0.0.0', // 监听地址
'port' => 2345, // 监听端口
'socket' => '', // 完整监听地址
'context' => [], // socket 上下文选项
'worker_class' => '', // 自定义Workerman服务类名 支持数组定义多个服务
// 支持workerman的所有配置参数
'name' => 'thinkphp',
'count' => 4,
'daemonize' => false,
'pidFile' => '',
// 支持事件回调
// onWorkerStart
'onWorkerStart' => function ($worker) {
},
// onWorkerReload
'onWorkerReload' => function ($worker) {
},
// onConnect
'onConnect' => function ($connection) {
},
// onMessage
'onMessage' => function ($connection, $data) {
$connection->send('receive success');
},
// onClose
'onClose' => function ($connection) {
},
// onError
'onError' => function ($connection, $code, $msg) {
echo "error [ $code ] $msg\n";
},
];