Skip to content

Commit

Permalink
Check if predis is installed via Composer
Browse files Browse the repository at this point in the history
  • Loading branch information
RobiNN1 committed Aug 30, 2023
1 parent cdfaa2b commit cbf6216
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
16 changes: 13 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,35 @@

declare(strict_types=1);

use Composer\InstalledVersions;
use RobiNN\Pca\Admin;
use RobiNN\Pca\Config;
use RobiNN\Pca\Http;
use RobiNN\Pca\Template;

if (PHP_VERSION_ID < 70400) {
die('<strong>PHP >= 7.4 is required.</strong><br>Currently installed version is: '.PHP_VERSION);
die('<strong>PHP >= 7.4 is required.</strong><br>The current version of php is: '.PHP_VERSION);
}

// always display errors
// Always display errors
ini_set('display_errors', 'On');
ini_set('display_startup_errors', 'On');
error_reporting(E_ALL);

$path = __DIR__.'/';

if (is_file(__DIR__.'/vendor/autoload.php')) {
require_once __DIR__.'/vendor/autoload.php';

if (!extension_loaded('redis') &&
InstalledVersions::isInstalled('predis/predis') === false &&
is_file($path.'predis.phar')
) {
require_once 'phar://'.$path.'predis.phar/vendor/autoload.php';
}
} else {
require_once __DIR__.'/src/functions.php';
autoload(__DIR__.'/');
autoload($path);
}

if (is_callable(Config::get('auth'))) {
Expand Down
1 change: 0 additions & 1 deletion src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ function autoload(string $path): void {
spl_autoload_register(static function (string $class_name) use ($path): void {
$class_name = str_replace("RobiNN\\Pca\\", '', $class_name);
$filename = str_replace("\\", DIRECTORY_SEPARATOR, $class_name);

$fullpath = $path.'src/'.$filename.'.php';

if (is_file($fullpath)) {
Expand Down

0 comments on commit cbf6216

Please sign in to comment.