This GitHub repo contains the following proof of concept:
- Using a static PHP CLI binary, it is possible to compile your PHP files from
.php
to.php.bin
with OPcache on any machine which matches your target OS (e.g. macOS) and architecture (e.g. arm64) - You are then able to zero out the
.php
files containing your PHP source code - Your app should then be packaged for your target OS and architecture, containing the
.php.bin
files, the empty.php
files and the static PHP CLI binary used in step #1 - Upon the app's first boot on the end-user's machine, a command should be run to distribute the
.php.bin
files according to the end-user's unique and absolute paths (you cannot use relative paths with OPcache)
- macOS (arm64 or x86_64)
- Git
- Composer
- PHP ^8.1
$ git clone https://github.com/chrisvpearse/opfuscate-poc.git
$ cd ./opfuscate-poc
$ composer install
$ cp .env.example .env
$ php artisan key:generate
The default web route is the empty ./app/Http/Controllers/HelloWorld.php
controller, however, when you launch the web server, you will see a welcome message which is being returned from HelloWorld.php.bin
in OPcache's file cache 🎉
$ php artisan opfuscate:install