PHP code example of rocareer / webman-status-code

1. Go to this page and download the library: Download rocareer/webman-status-code library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rocareer / webman-status-code example snippets


use support\StatusCode;

// 中间件/服务内抛业务异常(消息为中文提示,码为业务状态码,全局异常处理器统一转响应)
throw new UnauthorizedHttpException('凭证已过期 请重新登录', StatusCode::TOKEN_EXPIRED);

// 取任意码的中文消息(未登记返回 '未知错误')
$msg = StatusCode::getMessage(StatusCode::NO_TOKEN);

return [
    'enable' => true,
    'status_code_class' => new StatusCode(),   // 目标状态码类(support\StatusCode)
    'system_number' => 201,                    // 系统标识(8 位码前 3 位)
    'start_min_number' => 10000,               // 新增码起始范围,例如 10000-99999
    'status_scan_path' => [app_path()],        // 扫描路径列表,可自行扩充 config_path()/process/ 等
];
bash
php webman scode:run