Skip to content

Commit

Permalink
refactor: move CodeIgniter::resolvePlatformExtensions() to bootstrap.php
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Feb 18, 2024
1 parent 0cc1e91 commit 6bab1e1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
7 changes: 2 additions & 5 deletions system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,6 @@ public function __construct(App $config)
*/
public function initialize()
{
// Run this check for manual installations
if (! is_file(COMPOSER_PATH)) {
$this->resolvePlatformExtensions(); // @codeCoverageIgnore
}

// Set default locale on the server
Locale::setDefault($this->config->defaultLocale ?? 'en');

Expand All @@ -206,6 +201,8 @@ public function initialize()
* @throws FrameworkException
*
* @codeCoverageIgnore
*
* @deprecated 4.5.0 Moved to system/bootstrap.php.
*/
protected function resolvePlatformExtensions()
{
Expand Down
28 changes: 28 additions & 0 deletions system/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* the LICENSE file that was distributed with this source code.
*/

use CodeIgniter\Exceptions\FrameworkException;
use Config\Autoload;
use Config\Modules;
use Config\Paths;
Expand Down Expand Up @@ -96,6 +97,33 @@
require_once APPPATH . 'Config/Constants.php';
}

/*
* ---------------------------------------------------------------
* CHECK SYSTEM FOR MISSING REQUIRED PHP EXTENSIONS
* ---------------------------------------------------------------
*/

// Run this check for manual installations
if (! is_file(COMPOSER_PATH)) {
$requiredExtensions = [
'intl',
'json',
'mbstring',
];

$missingExtensions = [];

foreach ($requiredExtensions as $extension) {
if (! extension_loaded($extension)) {
$missingExtensions[] = $extension;
}
}

if ($missingExtensions !== []) {
throw FrameworkException::forMissingExtension(implode(', ', $missingExtensions));
}
}

/*
* ---------------------------------------------------------------
* LOAD COMMON FUNCTIONS
Expand Down

0 comments on commit 6bab1e1

Please sign in to comment.