pmmp / PHP-Binaries

Compile scripts used to build PHP for PocketMine-MP on multiple platforms
117 stars 169 forks source link

One try: Pack pmmp into a single file #185

Open crazywhalecc opened 9 months ago

crazywhalecc commented 9 months ago

I learned PHP seven years ago just to write PocketMine plugins, and now I'm getting ready to try setting up a bedrock server again, and it suddenly occurred to me that it would be possible to apply the static-php-cli I've been maintaining recently to pmmp?

The result is successful but not perfect. Here is a demo:

2023-12-21 22 05 45

pmmp-bin-linux-x86_64.zip

My build steps

  1. Add missing extensions and libraries for static-php-cli. Currently in branch pmmp-experiment.
  2. Download source: bin/spc download --for-extensions=pmmp-chunkutils2,curl,crypto,ctype,gmp,leveldb,mbstring,mbregex,morton,openssl,pmmpthread,sockets,yaml,zip,igbinary,zlib,phar,opcache --with-php=8.2 --debug.
  3. Build micro SAPI with ZTS, fake-cli mode: bin/spc build pmmp-chunkutils2,curl,crypto,ctype,gmp,leveldb,mbstring,mbregex,morton,openssl,pmmpthread,sockets,yaml,zip,igbinary,zlib,phar,opcache --build-cli --build-micro --enable-zts --debug --with-micro-fake-cli.
  4. Download PocketMine-MP.phar.
  5. Glue it: cat buildroot/bin/micro.sfx PocketMine-MP.phar > pmmp.app.
  6. chmod: chmod +x pmmp.app.
  7. Run once to init config and map: ./pmmp.app.
  8. Disable console input: pmmp.yml -> console.input: false.
  9. Run again: ./pmmp.app.

I also entered the game and connected to the server. Currently, it runs normally without any plugins.

Problems I found

I also tried to use --build-cli to generate standalone php and conducted a series of experiments on both macOS and Linux. An independent php-cli is currently more stable. But I don't have enough insight into how pmmp works and the stability of standalone version of these patched PHP extensions.

Anyway, I learned a lot of interesting extensions through this project of pmmp, and I am happy to show my experiments.