mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
PocketMine.php: clean up on platform dependency checks
This commit is contained in:
parent
6cad7be3ef
commit
670b940837
@ -53,26 +53,25 @@ namespace pocketmine {
|
|||||||
* Enjoy it as much as I did writing it. I don't want to do it again.
|
* Enjoy it as much as I did writing it. I don't want to do it again.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
function check_platform_dependencies(){
|
||||||
if(version_compare(MIN_PHP_VERSION, PHP_VERSION) > 0){
|
if(version_compare(MIN_PHP_VERSION, PHP_VERSION) > 0){
|
||||||
critical_error(\pocketmine\NAME . " requires PHP >= " . MIN_PHP_VERSION . ", but you have PHP " . PHP_VERSION . ".");
|
//If PHP version isn't high enough, anything below might break, so don't bother checking it.
|
||||||
critical_error("Please refer to the installation instructions at http://pmmp.rtfd.io/en/rtfd/installation.html.");
|
return [
|
||||||
exit(1);
|
\pocketmine\NAME . " requires PHP >= " . MIN_PHP_VERSION . ", but you have PHP " . PHP_VERSION . "."
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$messages = [];
|
||||||
|
|
||||||
if(PHP_INT_SIZE < 8){
|
if(PHP_INT_SIZE < 8){
|
||||||
critical_error("Running " . \pocketmine\NAME . " with 32-bit systems/PHP is no longer supported.");
|
$messages[] = "Running " . \pocketmine\NAME . " with 32-bit systems/PHP is no longer supported. Please upgrade to a 64-bit system, or use a 64-bit PHP binary if this is a 64-bit system.";
|
||||||
critical_error("Please upgrade to a 64-bit system, or use a 64-bit PHP binary if this is a 64-bit system.");
|
|
||||||
critical_error("Please refer to the installation instructions at http://pmmp.rtfd.io/en/rtfd/installation.html.");
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dependencies check */
|
|
||||||
|
|
||||||
$errors = 0;
|
|
||||||
|
|
||||||
if(php_sapi_name() !== "cli"){
|
if(php_sapi_name() !== "cli"){
|
||||||
critical_error("You must run " . \pocketmine\NAME . " using the CLI.");
|
$messages[] = "You must run " . \pocketmine\NAME . " using the CLI.";
|
||||||
++$errors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$extensions = [
|
$extensions = [
|
||||||
@ -97,8 +96,7 @@ namespace pocketmine {
|
|||||||
|
|
||||||
foreach($extensions as $ext => $name){
|
foreach($extensions as $ext => $name){
|
||||||
if(!extension_loaded($ext)){
|
if(!extension_loaded($ext)){
|
||||||
critical_error("Unable to find the $name ($ext) extension.");
|
$messages[] = "Unable to find the $name ($ext) extension.";
|
||||||
++$errors;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,28 +106,36 @@ namespace pocketmine {
|
|||||||
$pthreads_version = "0.$pthreads_version";
|
$pthreads_version = "0.$pthreads_version";
|
||||||
}
|
}
|
||||||
if(version_compare($pthreads_version, "3.1.7dev") < 0){
|
if(version_compare($pthreads_version, "3.1.7dev") < 0){
|
||||||
critical_error("pthreads >= 3.1.7dev is required, while you have $pthreads_version.");
|
$messages[] = "pthreads >= 3.1.7dev is required, while you have $pthreads_version.";
|
||||||
++$errors;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(extension_loaded("leveldb")){
|
if(extension_loaded("leveldb")){
|
||||||
$leveldb_version = phpversion("leveldb");
|
$leveldb_version = phpversion("leveldb");
|
||||||
if(version_compare($leveldb_version, "0.2.1") < 0){
|
if(version_compare($leveldb_version, "0.2.1") < 0){
|
||||||
critical_error("php-leveldb >= 0.2.1 is required, while you have $leveldb_version");
|
$messages[] = "php-leveldb >= 0.2.1 is required, while you have $leveldb_version.";
|
||||||
++$errors;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(extension_loaded("pocketmine")){
|
if(extension_loaded("pocketmine")){
|
||||||
critical_error("The native PocketMine extension is no longer supported.");
|
$messages[] = "The native PocketMine extension is no longer supported.";
|
||||||
++$errors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($errors > 0){
|
return $messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($messages = check_platform_dependencies())){
|
||||||
|
echo PHP_EOL;
|
||||||
|
$binary = version_compare(PHP_VERSION, "5.4") >= 0 ? PHP_BINARY : "unknown";
|
||||||
|
critical_error("Selected PHP binary ($binary) does not satisfy some requirements.");
|
||||||
|
foreach($messages as $m){
|
||||||
|
echo " - $m" . PHP_EOL;
|
||||||
|
}
|
||||||
critical_error("Please recompile PHP with the needed configuration, or refer to the installation instructions at http://pmmp.rtfd.io/en/rtfd/installation.html.");
|
critical_error("Please recompile PHP with the needed configuration, or refer to the installation instructions at http://pmmp.rtfd.io/en/rtfd/installation.html.");
|
||||||
|
echo PHP_EOL;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
unset($messages);
|
||||||
|
|
||||||
error_reporting(-1);
|
error_reporting(-1);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user