mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
11cc40d23a
* Scaffold test case * Import.php tests: - Basic test scaffold - Test if exception is thrown when unknown resource - Company update test * Migration importer & exception classes * Company migration test - Added 3rd parameter for accepting custom resources - Wip tax_rates migration * Tax rate migration * Tax rate update - Added company_id & user_id property modifiers * Users migration * Save IDs for users importing * Add 'transformIds' method * Importing clients - An exception for resource not migration - Dependency logic - Removing id on insert * Exception for unresolved dependency * Import clients * Method for inspecting user_id * Importing invoices * Importing quotes * Fix tests & wrap with try-catch * Fix tax_rates user_id transform * Working on migration * Tests for migration * fixes for test * Tests for Import.php - Added ext-json to composer.json * Tests for Import.php - Added ext-json to composer.json * Change migration exceptions to MigrationValidatorFailed * Fixes for tests and counters * Unzipping the migration archive - Changed .gitignore to ignore all local migrations * Comparing local data with inserted * Ignore verification - wip * Fix formatting for api.php * Uploading file test (wip) * Fix typo Co-authored-by: David Bomba <turbo124@gmail.com>
99 lines
2.4 KiB
PHP
99 lines
2.4 KiB
PHP
<?php
|
|
/**
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
*
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
*
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
|
*
|
|
* @license https://opensource.org/licenses/AAL
|
|
*/
|
|
|
|
namespace App\Utils;
|
|
|
|
use App\Libraries\MultiDB;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
/**
|
|
* Class SystemHealth.
|
|
*/
|
|
class SystemHealth
|
|
{
|
|
private static $extensions = [
|
|
'mysqli',
|
|
'gd',
|
|
'curl',
|
|
'zip',
|
|
'gmp'
|
|
];
|
|
|
|
private static $php_version = 7.3;
|
|
|
|
|
|
/**
|
|
* Check loaded extensions / PHP version / DB Connections
|
|
*
|
|
* @return array Result set of checks
|
|
*/
|
|
public static function check() : array
|
|
{
|
|
$system_health = true;
|
|
|
|
if (in_array(false, self::extensions())) {
|
|
$system_health = false;
|
|
} elseif (phpversion() < self::$php_version) {
|
|
$system_health = false;
|
|
}
|
|
|
|
return [
|
|
'system_health' => $system_health,
|
|
'extensions' => self::extensions(),
|
|
'php_version' => phpversion(),
|
|
'min_php_version' => self::$php_version,
|
|
'dbs' => self::dbCheck(),
|
|
];
|
|
}
|
|
|
|
private static function extensions() :array
|
|
{
|
|
$loaded_extensions = [];
|
|
|
|
foreach (self::$extensions as $extension) {
|
|
$loaded_extensions[] = [$extension => extension_loaded($extension)];
|
|
}
|
|
|
|
return $loaded_extensions;
|
|
}
|
|
|
|
private static function dbCheck() :array
|
|
{
|
|
$result = [];
|
|
|
|
if (! config('ninja.db.multi_db_enabled')) {
|
|
$pdo = DB::connection()->getPdo();
|
|
|
|
if ($pdo) {
|
|
$result[] = [ DB::connection()->getDatabaseName() => true ];
|
|
} else {
|
|
$result[] = [ config('database.connections.' . config('database.default') . '.database') => false ];
|
|
}
|
|
} else {
|
|
foreach (MultiDB::$dbs as $db) {
|
|
MultiDB::setDB($db);
|
|
|
|
$pdo = DB::connection()->getPdo();
|
|
|
|
if ($pdo) {
|
|
$result[] = [ DB::connection()->getDatabaseName() => true ];
|
|
} else {
|
|
$result[] = [ config('database.connections.' . config('database.default') . '.database') => false ];
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
|
}
|