Skip to content

Instantly share code, notes, and snippets.

@Halleck45
Last active September 26, 2025 15:11
Show Gist options
  • Save Halleck45/3b2fffa829d2af34235aa7355cdfb7f9 to your computer and use it in GitHub Desktop.
Save Halleck45/3b2fffa829d2af34235aa7355cdfb7f9 to your computer and use it in GitHub Desktop.
#
# Creating phar
# -------------------------------------
# Download
composer require --dev bamarni/composer-bin-plugin
composer bin box require --dev humbug/box
# Build phar
./vendor/bin/box compile
#
# Installing Static-php-cli (SPC)
# -------------------------------------
# Download
curl -fsSL \
-o spc.tgz \
https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-x86_64.tar.gz \
&& tar -zxvf spc.tgz && rm spc.tgz
# Dependencies
./spc doctor --auto-fix
./spc download --with-php=8.4 --for-extensions \
"apcu,curl,dom,fileinfo,filter,intl,mbstring,mysqlnd,openssl" \
--prefer-pre-built
# Optional (to optimize the final build)
./spc install-pkg upx
#
# Build the final binary
# -------------------------------------
# Build
./spc build --build-micro \
"apcu,curl,dom,fileinfo,filter,intl,mbstring,mysqlnd,openssl" \
--with-upx-pack
./spc micro:combine mon_fichier.phar \
--output=my-binary-linux-x86_64
chmod +x my-binary-linux-x86_64
# Now you can run:
./my-binary-linux-x86_64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment