lengbin / hyperf-error-code
hyperf error code
Installs: 2 293
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.2.0
- hyperf/command: ~2.0.0
- lengbin/error-code: dev-main
README
Hyperf Error Code Command
If You Like This Please Give Me Star
Install
The preferred way to install this extension is through composer.
Either run
composer require lengbin/hyperf-error-code
or add
"lengbin/hyperf-error-code": "*"
to the require section of your composer.json
file.
you can see document
Configs
// 配置 /config/autoload/errorCode.php return [ // 错误码文件 目录 'path' => [ BASE_PATH . '/app/Constant/Errors' ], // 合并生成 类 文件名称 'classname' => 'Error', // 合并生成 类 命名空间 'classNamespace' => 'App\\Constant', // 合并生成 类 文件输出目录 'output' => BASE_PATH . '/app/Constant', ]; class ErrorCode extends BaseEnum { /** * @Message("成功") */ const SUCCESS = '0'; } $error = ErrorCode::byValue(ErrorCode::SUCCESS); $error->getName(); // SUCCESS // 支持多语言 $error->getMessage([], 'zh-CN'); // 成功 $error->getValue(); // 0
Publish
php ./bin/hyperf.php vendor:publish lengbin/hyperf-error-code
Usage
php ./bin/hyperf.php gen:error-code