Hi list !

While I am still trying to fix bug 79714 (please see: https://bugs.php.net/bug.php?id=79714), I got a few ideas.

First though, let me say that I still need advice about fixing the bug above as per my earlier mail.

But now, my new idea:

For future versions of PHP (8.1 ?), I would like following additions to PHP:
The goal is still the same as what I am trying to achieve by fixing the 79714 bug, namely to be able to build PHARs that can be distributed as single-file while remaining harder to reverse-engineer.


Now about my changes:


Opcache:

opcache_compile_file_2_binfile(string $phpFile, string $outputBinFile)
New function which operates similar to opcache_compile_file() while compiling $phpFile into the binary OpCache bytecode and save it as $outputBinFile

Core:

requirebin(string $dotbin_file_path)
Like require() but the parameter is the parameter is the path to a .bin (opCache bytecode file)

includebin(string $dotbin_file_path)
Like include() but the parameter is the parameter is the path to a .bin (opCache bytecode file)

requirebin_once(string $dotbin_file_path)
Like require_once() but the parameter is the parameter is the path to a .bin (opCache bytecode file)

includebin_once(string $dotbin_file_path)
Like include_once() but the parameter is the parameter is the path to a .bin (opCache bytecode file)

Phar Extension:

Phar::addOpcacheFile(string $pathToOpCacheBinFile, string $localName)
Like Phar::addFile but first parameter is the path to a file produced by opcache_compile_file_2_binfile()
(requires the opcache extension to be present)

Phar::setOpcachedStub(string $code)
Like Phar::setStub(string $code) but $code is first converted into byte code (requires the opcache extension to be present).


I think these changes would mean that using an autoloader (ie. vendor/autoload.php) in the PHAR - which would contain a check to see if a .bin exists, then use includebin_once() to load it. If a .bin file does *NOT* exist but a .PHP file does, then simply use include_once() to load the PHP file - would allow for distributing PHARs that have their source code relatively well protected.


What do you guys think about my idea ?



Best regards,


Henrik Skov
Secuno A/S

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to