mirror of
https://github.com/lkeme/BiliHelper-personal.git
synced 2025-12-19 09:30:10 +08:00
[add] Env
This commit is contained in:
parent
ee2a62119f
commit
46930d28bd
@ -23,14 +23,7 @@ class App
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
set_time_limit(0);
|
(new Env())->set_configure()->inspect_extension();
|
||||||
error_reporting(E_ALL);
|
|
||||||
ini_set('display_errors', 'on');
|
|
||||||
header("Content-Type:text/html; charset=utf-8");
|
|
||||||
date_default_timezone_set('Asia/Shanghai');
|
|
||||||
if (PHP_SAPI != 'cli') {
|
|
||||||
die("Please run this script from command line");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
62
src/core/Env.php
Normal file
62
src/core/Env.php
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Website: https://mudew.com/
|
||||||
|
* Author: Lkeme
|
||||||
|
* License: The MIT License
|
||||||
|
* Email: Useri@live.cn
|
||||||
|
* Updated: 2020 ~ 2021
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace BiliHelper\Core;
|
||||||
|
|
||||||
|
class Env
|
||||||
|
{
|
||||||
|
private $app_name = 'BiliHelper Personal';
|
||||||
|
private $app_version = '0.3.0.*';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Env constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
Log::info("欢迎使用 {$this->app_name} 当前版本 {$this->app_version}");
|
||||||
|
Log::info("程序使用相关请移步 https://github.com/lkeme/BiliHelper-personal 文档部分查看。");
|
||||||
|
|
||||||
|
if (PHP_SAPI != 'cli') {
|
||||||
|
die("Please run this script from command line .");
|
||||||
|
}
|
||||||
|
if (version_compare(PHP_VERSION, '7.0.0', '<')) {
|
||||||
|
die("Please upgrade PHP version >= 7.0.0 .");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 检查扩展
|
||||||
|
*/
|
||||||
|
public function inspect_extension()
|
||||||
|
{
|
||||||
|
$default_extensions = ['curl', 'openssl', 'sockets', 'json', 'zlib', 'mbstring'];
|
||||||
|
foreach ($default_extensions as $extension) {
|
||||||
|
if (!extension_loaded($extension)) {
|
||||||
|
Log::error("检查到项目依赖 {$extension} 扩展未加载。");
|
||||||
|
Log::error("请在 php.ini中启用 {$extension} 扩展后重试。");
|
||||||
|
Log::error("程序常见问题请移步 https://github.com/lkeme/BiliHelper-personal 文档部分查看。");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @use 环境配置
|
||||||
|
*/
|
||||||
|
public function set_configure()
|
||||||
|
{
|
||||||
|
set_time_limit(0);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', 'on');
|
||||||
|
header("Content-Type:text/html; charset=utf-8");
|
||||||
|
date_default_timezone_set('Asia/Shanghai');
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user