Skip to content

Repository files navigation

PHP binaries & PHP build scripts for PocketMine-MP

Build status

Prebuilt binaries

Actively updated "latest" URLs

Legacy binaries, no longer updated

compile.sh

Bash script used to compile PHP on MacOS and Linux platforms. Make sure you have make autoconf automake libtool m4 wget getconf gzip bzip2 bison g++ git cmake pkg-config re2c ca-certificates.

Recommendations

  • If you're going to use the compiled binary only on the machine you're build it on, remove the -t option for best performance - this will allow the script to optimize for the current machine rather than a generic one.
  • ext-gd2 is NOT included unless the -g flag is provided, as PocketMine-MP doesn't need it. However, if your plugins need it, don't forget to enable it using -g.
  • The -c and -l options can be used to specify cache folders to speed up recompiling if you're recompiling many times (e.g. to improve the script).

Common pitfalls

  • Avoid using the script in directory trees containing spaces. Some libraries don't like trying to be built in directory trees containing spaces, e.g. /home/user/my folder/pocketmine-mp/ might experience problems.
  • Avoid directory trees containing special (non-English) symbols. For example, Développement might cause issues.

Additional notes

Mac OSX (native compile)

  • Most dependencies can be installed using Homebrew
  • You will additionally need glibtool (GNU libtool, xcode libtool won't work)

Android 64-bit (cross-compile)

  • Only aarch64 targets are supported for Android cross-compile.
  • The aarch64-linux-musl toolchain is required. You can compile and install it using https://github.com/pmmp/musl-cross-make (PMMP fork includes musl-libc patches for DNS resolver config path and increasing stack size limit for LevelDB)
Script flagsDescription
-cUses the folder specified for caching downloaded tarballs, zipballs etc.
-dCompiles with debugging symbols and disables optimizations (slow, but useful for debugging segfaults)
-DCompiles with separated debugging symbols, but leaves optimizations enabled (used for distributed binaries)
-gWill compile GD2
-FWill compile FFI
-jSet make threads to #
-lUses the folder specified for caching compilation artifacts (useful for rapid rebuild and testing)
-nDon't remove sources after completing compilation
-sWill compile everything statically
-tSet target
-vEnable Valgrind support in PHP
-xSpecifies we are doing cross-compile
-PSet target to the specified major PocketMine-MP version specified (currently only 5 is supported)
-zPHP version to build, e.g 8.2 (optional, if not specified, will be auto-selected by PM version)

Example:

TargetArguments
linux64-t linux64 -j4 -P5
linux64, PM4-t linux64 -j4 -P4
mac64-t mac-x86-64 -j4 -P5
android-aarch64-t android-aarch64 -x -j4 -P5

windows-compile-vs.ps1

Uses Visual Studio toolsets to compile PHP binaries on Windows. You need to install git, cmake and Visual Studio 2019 to use this script.

This script doesn't accept parameters, but the following environment variables are influential:

VariableDescription
PHP_DEBUG_BUILDDisables optimisations and builds PHP with detailed debugging information (useful for debugging segfaults)
SOURCES_PATHWhere to put the downloaded sources for compilation
PM_VERSION_MAJORMajor version of PocketMine-MP to build for (currently only 5 is supported)
PHP_VERSION_BASEPHP version to build, e.g 8.2 (optional, if not specified, will be auto-selected by PM version)
PHP_JIT_SUPPORTWhether to compile with OPcache JIT, set to 1 for yes

For developers: Version info sources

Libraries

Link to packageNeeded forNotes
zlibCompression
gmpBig integer math for Bedrock packet encryptionHosted at DependencyMirror to avoid service outages
curlWeb requests
libyamlParsing YAML config files
leveldbBedrock world supportCustom version based on google/leveldb with minimum required changes to support MCPE worlds
libxmlXML parsing support for UPnPHosted at DependencyMirror to avoid service outages
libpngphp-gd, plugin use onlyHosted at DependencyMirror to avoid service outages
libjpegphp-gd, plugin use onlyHosted at DependencyMirror to avoid service outages
opensslBedrock packet encryption, secure web requests
libzipResource packs
sqlite3Plugin use onlyHosted at DependencyMirror to avoid service outages
libdeflateFaster alternative to zlib for network use
pthreads4wNeeded by ext-pmmpthread on WindowsHosted at DependencyMirror to avoid service outages

PHP & extensions

Link to packageNeeded forNotes
PHPEverythingReplace 8.2 in the URL with your chosen version
pmmpthreadPHP threading
yamlYAML config parsingYes, the mix of - and _ is intentional. Don't ask me.
leveldbBedrock world supportCustom version to provide LEVELDB_ZLIB_RAW_COMPRESSION support
chunkutils2PalettedBlockArray and other low-level stuff
xdebugDebuggingNot needed for production
igbinaryFaster serialization, mostly for moving stuff between threadsNon-essential, could be ditched if necessary
cryptoBedrock packet encryption
recursionguardDebuggingNot needed for production
libdeflateFaster network compressionNon-essential but provides significant performance advantage over zlib
mortonPacking X/Z and X/Y/Z coordinates into ints in a format suitable for PHP array keysNeeded for performance
xxhashNot currently usedCould be replaced by hash() in recent versions of PHP but this extension has much better performance
arraydebugDebugging array hash collisions
encodingDisk & network data encoding & decodingSignificantly faster alternative to BinaryUtils

Misc

Link to packageNeeded forNotes
php-sdk-binary-toolsBuilding PHP on Windows

About

Compile scripts used to build PHP for PocketMine-MP on multiple platforms

Resources

Stars

9 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages