函数列表

swoole_get_license(string $license_files = '')

获取 license 授权文件信息。此函数为只读操作,必须在php.ini或者使用ini_set设置swoole_loader.license_files才可以使用

swoole_loader_version()

获取swoole_loader版本

异常列表

swoole_loader_exception

当 license 检测失败,或 Loader 配置为仅允许加载加密文件却加载了明文文件时,会抛出此异常。

可能的异常 code 和 error message 如下(尖括号中的内容为运行时实际值)。Code 同时注册为 PHP 全局常量,可用于比较 $e->getCode():

PHP 常量 Code Error message 触发情况
SWOOLE_LOADER_ERROR_UNENCRYPTED_FILE 1001 The copyright owner of the software requires that only encrypted files are allowed Loader 配置为仅允许加载加密文件,但当前加载的是明文文件
SWOOLE_LOADER_ERROR_LICENSE_FILES_NOT_CONFIGURED 1002 the encrypted file <filename> contains product_name, check whether license_files is correctly configured 加密文件设置了 product_name,但未配置 swoole_loader.license_files
SWOOLE_LOADER_ERROR_LICENSE_TABLE 1003 license table error 未能从配置的授权文件中加载到任何有效授权信息
SWOOLE_LOADER_ERROR_PRODUCT_NOT_FOUND 1004 product <product_name> can not find in license file 授权文件中不存在加密文件所需的 product_name
SWOOLE_LOADER_ERROR_PRODUCT_EXPIRED 1005 the product <product_name> auth has been expired 对应产品的授权已过期
SWOOLE_LOADER_ERROR_MAC_MISMATCH 1006 the error mac value, got <mac> in file <filename> 当前机器的 MAC 地址不在授权范围内
SWOOLE_LOADER_ERROR_IP_MISMATCH 1007 the error ip value, got <ip> in file <filename> 当前机器的 IP 地址不在授权范围内
SWOOLE_LOADER_ERROR_HOST_MISMATCH 1008 the error host value, got <host> in file <filename> 当前机器的主机名不在授权范围内
SWOOLE_LOADER_ERROR_LICENSE_SOURCE_MISMATCH 1009 the error license source 授权文件中的 license_source 与加密文件的编译器标识不一致

最后更新:2026-09-15