Set UTF-8 encoding for error messages

This commit is contained in:
printempw 2018-02-24 19:21:04 +08:00
parent 62af291091
commit 6448b3bbab
4 changed files with 30 additions and 9 deletions

View File

@ -53,7 +53,10 @@ class AppServiceProvider extends ServiceProvider
if (class_exists($className)) {
$this->app->singleton('cipher', $className);
} else {
exit(sprintf("No such encrypt method: [%s], please check your .env configuration.", config('secure.cipher')));
die_with_utf8_encoding(sprintf(
'[Error] Unsupported encryption method: < %1$s >, please check your .env configuration <br>'.
'[错误] 不支持的密码加密方式 < %1$s >,请检查你的 .env 配置文件'
, config('secure.cipher')));
}
$this->app->singleton('users', \App\Services\Repositories\UserRepository::class);

View File

@ -406,7 +406,7 @@ if (! function_exists('runtime_check')) {
{
foreach ($requirements['extensions'] as $extension) {
if (! extension_loaded($extension)) {
exit(
die_with_utf8_encoding(
"[Error] You have not installed the $extension extension <br>".
"[错误] 你尚未安装 $extension 扩展!安装方法请自行搜索,蟹蟹。"
);
@ -416,16 +416,32 @@ if (! function_exists('runtime_check')) {
foreach (array_get($requirements, 'write_permission', []) as $dir) {
$realPath = realpath(__DIR__."/../$dir");
if (! file_exists($realPath)) {
die_with_utf8_encoding(
"[Error] The directory < $dir > does not exist <br>".
"[错误] 目录 < $dir > 不存在,请在程序根目录下手动创建"
);
}
if (! is_writable($realPath)) {
exit(
"[Error] The program lacks write permission to directory $dir <br>".
"[错误] 程序缺少对 $dir 目录的写权限或目录不存在,请手动授权/创建"
die_with_utf8_encoding(
"[Error] The program lacks write permission to directory < $dir > <br>".
"[错误] 程序缺少对 < $dir > 目录的写权限,请手动授权"
);
}
}
}
}
if (! function_exists('die_with_utf8_encoding')) {
function die_with_utf8_encoding($error)
{
header('Content-Type: text/html; charset=UTF-8');
exit($error);
}
}
if (! function_exists('get_db_type')) {
function get_db_type($type = null)

View File

@ -17,9 +17,10 @@ define('LARAVEL_START', microtime(true));
if (file_exists($autoload = __DIR__.'/../vendor/autoload.php')) {
require $autoload;
} else {
header('Content-Type: text/html; charset=UTF-8');
exit(
"No vendor folder found. Have you installed the dependencies with composer? <br>".
"根目录下未发现 vendor 文件夹,请参照安装说明使用 composer 安装依赖库。"
"[Error] No vendor folder found. Have you installed the dependencies with composer? <br>".
"[错误] 根目录下未发现 vendor 文件夹,请使用 composer 安装依赖库。详情请阅读 http://t.cn/REyMUqA"
);
}

View File

@ -11,9 +11,10 @@
// Check PHP version
if (version_compare(PHP_VERSION, '5.5.9', '<')) {
header('Content-Type: text/html; charset=UTF-8');
exit(
'[Error] Blessing Skin Server needs PHP version >= 5.5.9, you are now using '.PHP_VERSION.'<br>'.
'[错误] 你的 PHP 版本过低('.PHP_VERSION.'Blessing Skin Server 要求至少为 5.5.9'
'[Error] Blessing Skin requires PHP version >= 5.5.9, you are now using '.PHP_VERSION.'<br>'.
'[错误] 你的 PHP 版本过低('.PHP_VERSION.'Blessing Skin 要求至少为 5.5.9'
);
}