PHP

PHP Code Compression Tool by removing whitespace, strips comments - PHP Minifier/Compressor

CK CK 3788 
Created at
Updated at  
1,404 0 0

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 

Tags Code Compression PHP Compressor PHP Minfier PHP Minify PHP Obfuscator Facebook X
Comments 0
  1. Useful code for file-based Unit Test in PHP
    498
  2. Function Overloading Implementation in PHP with Magic Mathods
    1,752
  3. PHP Magic - the Null Coalescing Operator (??) - return the value if the give variable is NULL
    1,666
  4. How do I find php.ini on Mac?
    490
  5. Mastering Excel Data Importation in PHP
    553
  6. Create Blob Image in HTML based on the given Text, Width and Height in the Center of the Image without saving file
    963
  7. How do I determine the client IP type (IPv4/IPv6) in PHP
    829
  8. What is 302 Found Redirection in HTTP 1.1?
    489
  9. Implementing a Versatile DNS Server in PHP: Handling A, AAAA, CNAME, and TXT Records
    615
  10. Building a Basic DNS Server in PHP/Python: A Beginner's Guide
    735
  11. CentOS 7 PHP Apache Kafka: Installation, Examples, and System Diagram
    305
  12. Apache Kafka Explained: Powering Netflix, Building with PHP
    489
  13. Array of arguments passed to script in PHP
    85
  14. Bob Jenkins' One-At-A-Time hashing algorithm in PHP
    50
  15. 32bits simple hash function in PHP
    36
  16. Setup Apache+PHP+MySQL on Centos 6.7
    605
  17. mcrypt missing when using phpMyAdmin on Centos 6.7
    546
  18. PHP Code can know the current OS is windows or not
    582
  19. Checking similarity between two strings in PHP
    674
  20. Simple PHP calendar
    473
  21. Simple PHP code performance measuring example
    791
  22. Convert plain HTML to XHTML
    451
  23. GD library version in PHP
    503
  24. JSON format control in PHP
    690
  25. mysql optimization – if you are using Word Press, do not turn off persistent connection
    589
  26. File downloading function through PHP code
    531
  27. Image file resizing in PHP
    561
  28. Apache server unstable detection and the related server(mysql, apache) restart automatically
    532
  29. How to set AUTO_INCREMENT ID in mySQL ?
    606
  30. Function can extract file name in string having full path in PHP
    565
Recently updated
  1. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    27
  2. Why SPF and DKIM Are Essential for Linux Email Servers?
    24
  3. How do I create animated background for Google Meet?
    19,708
  4. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    217
  5. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    85
  6. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    153
  7. Array of arguments passed to script in PHP
    85
  8. Invalid Auction Storms in Ad Tech
    93
  9. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    197
  10. The Two Clocks of Ad Server Architecture
    63
  11. Frequency Cap Architecture Overview
    509
  12. Collecting Proof-of-Play from 100,000 Screens
    141
  13. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    280
  14. What is RedisVL?
    105
  15. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    224
  16. TPU & GPU Cluster Management Tools
    232
  17. The Concept of Scaffolding in AI Agents
    221
  18. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    575
  19. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    252
  20. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    326
  21. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    197
  22. Machine Learning: Training vs. Ranking
    213
  23. The Continuous Learning Machine: Designing a Loop That Actually Turns
    217
  24. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    189
  25. Designing a Data Curation System Around a Vector Database
    215
  26. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    229
  27. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    649
  28. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    185
  29. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    207
  30. Understanding Data Lineage
    252