require redis and use reids to check ReAnnounce

This commit is contained in:
xiaomlove
2022-02-19 23:19:09 +08:00
parent 80bf8a29ff
commit f2f873e1e7
11 changed files with 53 additions and 40 deletions

View File

@@ -126,7 +126,7 @@ class Install
public function listRequirementTableRows()
{
$gdInfo = function_exists('gd_info') ? gd_info() : [];
$extensions = ['ctype', 'fileinfo', 'json', 'mbstring', 'openssl', 'pdo_mysql', 'tokenizer', 'xml', 'mysqli', 'gd', 'bcmath'];
$extensions = ['ctype', 'fileinfo', 'json', 'mbstring', 'openssl', 'pdo_mysql', 'tokenizer', 'xml', 'mysqli', 'bcmath', 'redis', 'gd'];
$tableRows = [];
$tableRows[] = [
'label' => 'PHP version',
@@ -160,12 +160,6 @@ class Install
'current' => $gdInfo['GIF Read Support'] ?? '',
'result' => $this->yesOrNo($gdInfo['GIF Read Support'] ?? ''),
];
$tableRows[] = [
'label' => 'PHP extension redis',
'required' => 'optional',
'current' => extension_loaded('redis'),
'result' => $this->yesOrNo(extension_loaded('redis')),
];
$fails = array_filter($tableRows, function ($value) {return in_array($value['required'], ['true', 'enabled']) && $value['result'] == 'NO';});
$pass = empty($fails);
@@ -434,15 +428,13 @@ class Install
$this->doLog("[CREATE ENV] final newData: " . json_encode($newData));
unset($key, $value);
mysql_connect($newData['DB_HOST'], $newData['DB_USERNAME'], $newData['DB_PASSWORD'], $newData['DB_DATABASE'], $newData['DB_PORT']);
if (extension_loaded('redis') && !empty($newData['REDIS_HOST'])) {
$redis = new \Redis();
$redis->connect($newData['REDIS_HOST'], $newData['REDIS_PORT'] ?: 6379);
if (isset($newData['REDIS_DB'])) {
if (!ctype_digit($newData['REDIS_DB']) || $newData['REDIS_DB'] < 0 || $newData['REDIS_DB'] > 15) {
throw new \InvalidArgumentException("invalid redis database: " . $newData['REDIS_DB']);
}
$redis->select($newData['REDIS_DB']);
$redis = new \Redis();
$redis->connect($newData['REDIS_HOST'], $newData['REDIS_PORT'] ?: 6379);
if (isset($newData['REDIS_DB'])) {
if (!ctype_digit($newData['REDIS_DB']) || $newData['REDIS_DB'] < 0 || $newData['REDIS_DB'] > 15) {
throw new \InvalidArgumentException("invalid redis database: " . $newData['REDIS_DB']);
}
$redis->select($newData['REDIS_DB']);
}
$content = "";
foreach ($newData as $key => $value) {

View File

@@ -173,7 +173,6 @@ if (!empty($error)) {
echo $install->renderTable($header, $requirements['table_rows']);
} elseif ($currentStep == 2) {
echo $install->renderTable($header, $tableRows);
echo '<div class="text-gray-700 p-4 text-red-400">若 Redis 不启用,相关项目留空</div>';
echo $install->renderForm($envFormControls);
} elseif ($currentStep == 3) {

View File

@@ -200,7 +200,7 @@ if (!empty($error)) {
echo $update->renderTable($header, $requirements['table_rows']);
} elseif ($currentStep == 3) {
echo $update->renderTable($header, $tableRows);
echo '<div class="text-gray-700 p-4 text-red-400">若 Redis 不启用,相关项目留空</div>';
echo '<div class="text-gray-700 p-4 text-red-400">下一步之前,请确保在根目录执行了 composer install 更新了依赖。</div>';
echo $update->renderForm($envFormControls);
} elseif ($currentStep == 2) {