Skip to content

Commit f9f5173

Browse files
committed
chore: update index.php and spark
1 parent caf8b8f commit f9f5173

File tree

2 files changed

+43
-94
lines changed

2 files changed

+43
-94
lines changed

public/index.php

Lines changed: 21 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
<?php
22

3-
// Check PHP version.
4-
$minPhpVersion = '7.4'; // If you update this, don't forget to update `spark`.
3+
/*
4+
*---------------------------------------------------------------
5+
* CHECK PHP VERSION
6+
*---------------------------------------------------------------
7+
*/
8+
9+
$minPhpVersion = '8.1'; // If you update this, don't forget to update `spark`.
510
if (version_compare(PHP_VERSION, $minPhpVersion, '<')) {
611
$message = sprintf(
712
'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s',
813
$minPhpVersion,
914
PHP_VERSION
1015
);
1116

12-
exit($message);
17+
header('HTTP/1.1 503 Service Unavailable.', true, 503);
18+
echo $message;
19+
20+
exit(1);
1321
}
1422

23+
/*
24+
*---------------------------------------------------------------
25+
* SET THE CURRENT DIRECTORY
26+
*---------------------------------------------------------------
27+
*/
28+
1529
// Path to the front controller (this file)
1630
define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR);
1731

@@ -29,59 +43,14 @@
2943
* and fires up an environment-specific bootstrapping.
3044
*/
3145

32-
// Load our paths config file
46+
// LOAD OUR PATHS CONFIG FILE
3347
// This is the line that might need to be changed, depending on your folder structure.
3448
require FCPATH . '../app/Config/Paths.php';
3549
// ^^^ Change this line if you move your application folder
3650

3751
$paths = new Config\Paths();
3852

39-
// Location of the framework bootstrap file.
40-
require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php';
41-
42-
// Load environment settings from .env files into $_SERVER and $_ENV
43-
require_once SYSTEMPATH . 'Config/DotEnv.php';
44-
(new CodeIgniter\Config\DotEnv(ROOTPATH))->load();
45-
46-
// Define ENVIRONMENT
47-
if (! defined('ENVIRONMENT')) {
48-
define('ENVIRONMENT', env('CI_ENVIRONMENT', 'production'));
49-
}
50-
51-
// Load Config Cache
52-
// $factoriesCache = new \CodeIgniter\Cache\FactoriesCache();
53-
// $factoriesCache->load('config');
54-
// ^^^ Uncomment these lines if you want to use Config Caching.
55-
56-
/*
57-
* ---------------------------------------------------------------
58-
* GRAB OUR CODEIGNITER INSTANCE
59-
* ---------------------------------------------------------------
60-
*
61-
* The CodeIgniter class contains the core functionality to make
62-
* the application run, and does all the dirty work to get
63-
* the pieces all working together.
64-
*/
65-
66-
$app = Config\Services::codeigniter();
67-
$app->initialize();
68-
$context = is_cli() ? 'php-cli' : 'web';
69-
$app->setContext($context);
70-
71-
/*
72-
*---------------------------------------------------------------
73-
* LAUNCH THE APPLICATION
74-
*---------------------------------------------------------------
75-
* Now that everything is set up, it's time to actually fire
76-
* up the engines and make this app do its thang.
77-
*/
78-
79-
$app->run();
80-
81-
// Save Config Cache
82-
// $factoriesCache->save('config');
83-
// ^^^ Uncomment this line if you want to use Config Caching.
53+
// LOAD THE FRAMEWORK BOOTSTRAP FILE
54+
require $paths->systemDirectory . '/Boot.php';
8455

85-
// Exits the application, setting the exit code for CLI-based applications
86-
// that might be watching.
87-
exit(EXIT_SUCCESS);
56+
exit(CodeIgniter\Boot::bootWeb($paths));

spark

Lines changed: 22 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,30 @@
1212

1313
/*
1414
* --------------------------------------------------------------------
15-
* CodeIgniter command-line tools
15+
* CODEIGNITER COMMAND-LINE TOOLS
1616
* --------------------------------------------------------------------
1717
* The main entry point into the CLI system and allows you to run
1818
* commands and perform maintenance on your application.
19-
*
20-
* Because CodeIgniter can handle CLI requests as just another web request
21-
* this class mainly acts as a passthru to the framework itself.
19+
*/
20+
21+
/*
22+
*---------------------------------------------------------------
23+
* CHECK SERVER API
24+
*---------------------------------------------------------------
2225
*/
2326

2427
// Refuse to run when called from php-cgi
2528
if (strpos(PHP_SAPI, 'cgi') === 0) {
2629
exit("The cli tool is not supported when running php-cgi. It needs php-cli to function!\n\n");
2730
}
2831

29-
// Check PHP version.
30-
$minPhpVersion = '7.4'; // If you update this, don't forget to update `public/index.php`.
32+
/*
33+
*---------------------------------------------------------------
34+
* CHECK PHP VERSION
35+
*---------------------------------------------------------------
36+
*/
37+
38+
$minPhpVersion = '8.1'; // If you update this, don't forget to update `public/index.php`.
3139
if (version_compare(PHP_VERSION, $minPhpVersion, '<')) {
3240
$message = sprintf(
3341
'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s',
@@ -42,12 +50,11 @@ if (version_compare(PHP_VERSION, $minPhpVersion, '<')) {
4250
error_reporting(E_ALL);
4351
ini_set('display_errors', '1');
4452

45-
/**
46-
* @var bool
47-
*
48-
* @deprecated No longer in use. `CodeIgniter` has `$context` property.
53+
/*
54+
*---------------------------------------------------------------
55+
* SET THE CURRENT DIRECTORY
56+
*---------------------------------------------------------------
4957
*/
50-
define('SPARKED', true);
5158

5259
// Path to the front controller
5360
define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR);
@@ -64,41 +71,14 @@ chdir(FCPATH);
6471
* and fires up an environment-specific bootstrapping.
6572
*/
6673

67-
// Load our paths config file
74+
// LOAD OUR PATHS CONFIG FILE
6875
// This is the line that might need to be changed, depending on your folder structure.
6976
require FCPATH . '../app/Config/Paths.php';
7077
// ^^^ Change this line if you move your application folder
7178

7279
$paths = new Config\Paths();
7380

74-
// Location of the framework bootstrap file.
75-
require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'bootstrap.php';
76-
77-
// Load environment settings from .env files into $_SERVER and $_ENV
78-
require_once SYSTEMPATH . 'Config/DotEnv.php';
79-
(new CodeIgniter\Config\DotEnv(ROOTPATH))->load();
80-
81-
// Define ENVIRONMENT
82-
if (! defined('ENVIRONMENT')) {
83-
define('ENVIRONMENT', env('CI_ENVIRONMENT', 'production'));
84-
}
85-
86-
// Grab our CodeIgniter
87-
$app = Config\Services::codeigniter();
88-
$app->initialize();
89-
90-
// Grab our Console
91-
$console = new CodeIgniter\CLI\Console();
92-
93-
// Show basic information before we do anything else.
94-
if (is_int($suppress = array_search('--no-header', $_SERVER['argv'], true))) {
95-
unset($_SERVER['argv'][$suppress]); // @codeCoverageIgnore
96-
$suppress = true;
97-
}
98-
99-
$console->showHeader($suppress);
100-
101-
// fire off the command in the main framework.
102-
$exit = $console->run();
81+
// LOAD THE FRAMEWORK BOOTSTRAP FILE
82+
require $paths->systemDirectory . '/Boot.php';
10383

104-
exit(is_int($exit) ? $exit : EXIT_SUCCESS);
84+
exit(CodeIgniter\Boot::bootSpark($paths));

0 commit comments

Comments
 (0)