'components' => [
'i18n' => [
'translations' => [
'common/*' => [
'class' => 'yii\i18n\PhpMessageSource',
'forceTranslation' => true,
'basePath' => '@common/messages',
'fileMap' => [
'common/app' => 'app.php',
'common/error' => 'error.php',
'common/success' => 'success.php',
],
],
'model/*' => [
'class' => 'yii\i18n\PhpMessageSource',
'forceTranslation' => true,
'basePath' => '@common/messages',
],
'*' => [
'class' => 'yii\i18n\PhpMessageSource',
'forceTranslation' => true,
'basePath' => '@app/messages',
'fileMap' => [
'app' => 'app.php',
'error' => 'error.php',
'success' => 'success.php',
],
],
],
],
],
<pre class="wp-block-syntaxhighlighter-code">
<?php
return [
20000 => 'error',
201001 => '框架服务控制台HTTP请求失败,状态码:{status_code}',
201002 => '框架服务控制台HTTP请求失败:{first_error}',
201003 => '框架服务控制台HTTP请求失败:{message}',
201004 => '框架服务接口HTTP请求失败,状态码:{status_code}',
201005 => '框架服务接口HTTP请求失败:{first_error}',
];
</pre>
<pre class="wp-block-syntaxhighlighter-code">
<?php
return [
10000 => 'success',
];
</pre>
<pre class="wp-block-syntaxhighlighter-code">
<?php
return [
20000 => 'error',
224001 => '日志列表为空',
224002 => '日志ID:{id},不存在',
224003 => '数据过滤器验证失败:{first_error}',
224004 => '用户ID:{id},的状态为已禁用',
224005 => '页面列表为空',
224006 => '页面ID:{id},不存在',
224007 => '页面ID:{id},的状态为已删除',
224008 => '页面ID:{id},的状态为已禁用',
224009 => '页面ID:{id},的状态为草稿',
226001 => '用户列表为空',
226002 => '用户ID:{id},不存在',
226003 => '用户ID:{id},的状态为已删除',
226004 => '数据验证失败:{first_error}',
];
</pre>
<pre class="wp-block-syntaxhighlighter-code">
<?php
return [
10000 => 'success',
124001 => '获取日志列表成功',
124002 => '获取日志详情成功',
124003 => '获取页面列表成功',
124004 => '获取页面详情成功',
124005 => '创建页面成功',
124006 => '更新页面成功',
124007 => '删除页面成功',
126001 => '获取用户列表成功',
126002 => '获取用户详情成功',
126003 => '创建用户成功',
126004 => '更新用户成功',
126005 => '删除用户成功',
];
</pre>
throw new ServerErrorHttpException(Yii::t('common/error', Yii::t('common/error', Yii::t('common/error', '201001'), ['status_code' => $response->getStatusCode()])), 201001);
return ['code' => 226004, 'message' => Yii::t('error', Yii::t('error', Yii::t('error', '226004'), ['first_error' => $firstError]))];
'components' => [
'i18n' => [
'translations' => [
'model/*' => [
'class' => 'yii\i18n\PhpMessageSource',
'forceTranslation' => true,
'basePath' => '@common/messages',
],
'*' => [
'class' => 'yii\i18n\PhpMessageSource',
'forceTranslation' => true,
'basePath' => '@app/messages',
'fileMap' => [
'app' => 'app.php',
'error' => 'error.php',
'success' => 'success.php',
],
],
],
],
],
<pre class="wp-block-syntaxhighlighter-code">
<?php
$commonMessages = require __DIR__ . '/../../../common/messages/zh-CN/error.php';
$messages = [
224001 => '日志列表为空',
224002 => '日志ID:{id},不存在',
224003 => '数据过滤器验证失败:{first_error}',
224004 => '用户ID:{id},的状态为已禁用',
224005 => '页面列表为空',
224006 => '页面ID:{id},不存在',
224007 => '页面ID:{id},的状态为已删除',
224008 => '页面ID:{id},的状态为已禁用',
224009 => '页面ID:{id},的状态为草稿',
226001 => '用户列表为空',
226002 => '用户ID:{id},不存在',
226003 => '用户ID:{id},的状态为已删除',
226004 => '数据验证失败:{first_error}',
];
return $commonMessages + $messages;
</pre>
<pre class="wp-block-syntaxhighlighter-code">
<?php
$commonMessages = require __DIR__ . '/../../../common/messages/zh-CN/success.php';
$messages = [
124001 => '获取日志列表成功',
124002 => '获取日志详情成功',
124003 => '获取页面列表成功',
124004 => '获取页面详情成功',
124005 => '创建页面成功',
124006 => '更新页面成功',
124007 => '删除页面成功',
126001 => '获取用户列表成功',
126002 => '获取用户详情成功',
126003 => '创建用户成功',
126004 => '更新用户成功',
126005 => '删除用户成功',
];
return $commonMessages + $messages;
</pre>
throw new ServerErrorHttpException(Yii::t('error', Yii::t('error', Yii::t('error', '201001'), ['status_code' => $response->getStatusCode()])), 201001);
return ['code' => 226004, 'message' => Yii::t('error', Yii::t('error', Yii::t('error', '226004'), ['first_error' => $firstError]))];
PHP / Laravel / Yii2 老项目维护与长期技术支持
如果你的 PHP / Laravel / Yii2 项目已经上线,但遇到原开发离职、Bug 长期无人修复、接口不稳定、性能下降、代码难以接手等问题,可以联系我做一次远程技术排查。
适合以下情况:
✅ 老旧 PHP 系统无人维护
✅ Laravel / Yii2 项目 Bug 修复
✅ 后台管理系统小功能迭代
✅ RESTful API 接口排查
✅ MySQL / Redis / Nginx 性能问题
✅ 长期远程兼职维护
可先从一次小问题开始:
✅ 线上报错排查
✅ 接口异常分析
✅ 慢查询与性能瓶颈定位
✅ 代码结构初步评估
✅ 部署环境与日志检查
如需咨询,请联系我,并注明:PHP 维护咨询。
联系方式:
Telegram:@shuijingwan
微信:13980074657
邮箱:shuijingwanwq@gmail.com

发表回复