-
Notifications
You must be signed in to change notification settings - Fork 175
Description
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:
My build steps
- Add missing extensions and libraries for static-php-cli. Currently in branch pmmp-experiment.
- 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
. - 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
. - Download PocketMine-MP.phar.
- Glue it:
cat buildroot/bin/micro.sfx PocketMine-MP.phar > pmmp.app
. - chmod:
chmod +x pmmp.app
. - Run once to init config and map:
./pmmp.app
. - Disable console input:
pmmp.yml -> console.input: false
. - Run again:
./pmmp.app
.
I also entered the game and connected to the server. Currently, it runs normally without any plugins.
Problems I found
- pmmp console input cannot be used with micro SAPI, because micro SAPI
PHP_BINARY
is empty, there is nophp-cli
executable. - phar file loading is not working perfectly (usually I use micro with phar needs
require_once
at the entry of phar). - the executable must be named with
yyy.xxx
(contains dot). - Warning message:
Debugging assertions are enabled
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.