-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: create spark.php in system/, require by spark #8779
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b5f5a7b
refactor: create spark.php in system/, require by spark
samsonasik 9023652
run rector on system/spark.php
samsonasik 986c78c
update comment in index.php
samsonasik 897c3a3
cs fix
samsonasik ab81d1d
update to use require in spark
samsonasik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of CodeIgniter 4 framework. | ||
* | ||
* (c) CodeIgniter Foundation <[email protected]> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
use CodeIgniter\Boot; | ||
use Config\Paths; | ||
|
||
/* | ||
* -------------------------------------------------------------------- | ||
* CODEIGNITER COMMAND-LINE TOOLS | ||
* -------------------------------------------------------------------- | ||
* The main entry point into the CLI system and allows you to run | ||
* commands and perform maintenance on your application. | ||
*/ | ||
|
||
/* | ||
*--------------------------------------------------------------- | ||
* CHECK SERVER API | ||
*--------------------------------------------------------------- | ||
*/ | ||
|
||
// Refuse to run when called from php-cgi | ||
if (str_starts_with(PHP_SAPI, 'cgi')) { | ||
exit("The cli tool is not supported when running php-cgi. It needs php-cli to function!\n\n"); | ||
} | ||
|
||
/* | ||
*--------------------------------------------------------------- | ||
* CHECK PHP VERSION | ||
*--------------------------------------------------------------- | ||
*/ | ||
|
||
$minPhpVersion = '8.1'; // If you update this, don't forget to update `public/index.php`. | ||
if (version_compare(PHP_VERSION, $minPhpVersion, '<')) { | ||
$message = sprintf( | ||
'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s', | ||
$minPhpVersion, | ||
PHP_VERSION | ||
); | ||
|
||
exit($message); | ||
} | ||
|
||
// We want errors to be shown when using it from the CLI. | ||
error_reporting(E_ALL); | ||
ini_set('display_errors', '1'); | ||
|
||
/* | ||
*--------------------------------------------------------------- | ||
* SET THE CURRENT DIRECTORY | ||
*--------------------------------------------------------------- | ||
*/ | ||
|
||
// Path to the front controller | ||
define('FCPATH', getcwd() . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR); | ||
|
||
if (! is_dir(FCPATH)) { | ||
throw new RuntimeException('ensure spark file in root project with public/ dir exists'); | ||
} | ||
|
||
// Ensure the current directory is pointing to the front controller's directory | ||
chdir(FCPATH); | ||
|
||
/* | ||
*--------------------------------------------------------------- | ||
* BOOTSTRAP THE APPLICATION | ||
*--------------------------------------------------------------- | ||
* This process sets up the path constants, loads and registers | ||
* our autoloader, along with Composer's, loads our constants | ||
* and fires up an environment-specific bootstrapping. | ||
*/ | ||
|
||
// LOAD OUR PATHS CONFIG FILE | ||
// This is the line that might need to be changed, depending on your folder structure. | ||
require FCPATH . '../app/Config/Paths.php'; | ||
// ^^^ Change this line if you move your application folder | ||
|
||
$paths = new Paths(); | ||
|
||
// LOAD THE FRAMEWORK BOOTSTRAP FILE | ||
require $paths->systemDirectory . '/Boot.php'; | ||
|
||
exit(Boot::bootSpark($paths)); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, we cannot modify
system/spark.php
.How do we do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see, the idea is to reduce manual change
The another way is make php requirment in single file under system, can also read CodeIgniter composer.json (yes, it make another include/read file, but reduce maintenance needs), eg:
system/requirement.php
so it included in both spark and public/index.php so once requirement change, it will only require composer upThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another way is make
app/Config/Paths.php
as an.env
value, egso it configurable there, default no data, fallback to default path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think including
system/requirement.php
is better.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually,
$paths->systemDirectory
is not needed here, as already inside the directory, I will create new commit.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, it needed on
exit(Boot::bootSpark($paths));
as passPaths
objectThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need the
Paths
instance first..env
is loaded inBoot
class.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, closing for now.