Skip to content
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

One try: Pack pmmp into a single file #185

Open
crazywhalecc opened this issue Dec 21, 2023 · 0 comments
Open

One try: Pack pmmp into a single file #185

crazywhalecc opened this issue Dec 21, 2023 · 0 comments

Comments

@crazywhalecc
Copy link

crazywhalecc commented Dec 21, 2023

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

  • pmmp console input cannot be used with micro SAPI, because micro SAPI PHP_BINARY is empty, there is no php-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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant