| Today, I received a question about whether it's possible to convert PHP code into a binary format or obfuscate it to prevent unauthorized modification. PHP code typically contains not only executable commands but also comments. Furthermore, spaces and other formatting are often added to improve readability. While searching for a tool to easily clean this up, I found PHP Minifier/Compressor. Code compression, achieved by removing whitespace and comments, reduces file size, leading to faster download and transmission times. This improves performance, particularly beneficial for web applications and embedded systems where bandwidth and storage are limited. Smaller code size also contributes to reduced memory consumption during execution. There is some open-source software that can do it, and yakpro-po is something people likes even though it has some bugs that haven't resolved. Setup:Note: This setup is also valid for Windows 10 Anniversary with bash installed...
1. Prerequisites: git and php-cli (command line interface) packages.
on ubuntu: (adapt according your linux distribution)
# apt install git
# apt install php-cli
do not forget to install all other php modules that you are using within your software:
for example: apt install php-mysql if you are using mysql...
2. Navigate to the directory where you want to install yakpro-po (/usr/local is a good idea):
# cd /usr/local
3. Then retrieve from GitHub:
# git clone https://github.com/pk-fr/yakpro-po.git
4. Go to the yakpro-po directory:
# cd yakpro-po
5. Then retrieve from GitHub:
# git clone https://github.com/nikic/PHP-Parser.git --branch 4.x
6. Check that yakpro-po.php has execute rights, otherwise:
# chmod a+x yakpro-po.php
7. Create a symbolic link in the /usr/local/bin directory
# cd /usr/local/bin
# ln -s /usr/local/yakpro-po/yakpro-po.php yakpro-po
8. You can now run yakpro-po
# yakpro-po --help
# yakpro-po test.php
Modify a copy of the yakpro-po.cnf to fit your needs...
Read the "Configuration file loading algorithm" section of this document
to choose the best location suiting your needs!
That's it! You're done!
Usage:yakpro-po Obfuscates according configuration file! (See configuration file loading algorithm)
yakpro-po source_filename Obfuscates code to stdout
yakpro-po source_filename -o target_filename Obfuscates code to target_filename
yakpro-po source_directory -o target_directory Recursivly obfuscates code to target_directory/yakpro-po (creates it if it does not already exist).
yakpro-po --config-file config_file_path According to config_file_path.
yakpro-po --clean Requires target_directory to be present in your config file! Recursivly removes target_directory/yakpro-po
You may able to have more information at https://github.com/pk-fr/yakpro-po.git |