See our review from 5 of the Best Open Source Libraries to obfuscate PHP code.

Top 5: Best Open Source PHP Code Obfuscator Libraries

Let's be honest, programming sometimes isn't so easy as we think, we spend a lot of time writing code, debugging etc, so the last thing we want and need is that after all the effort is simply copied by someone else, reusing your code (and not specifically within your organization). Fortunately, there are techniques that allow you to prevent this situation from happening, the most known is the area of obfuscation. Basically, the obfuscation should completely alter the source code, however its functionality should be equivalent to the original code. In PHP, the obfuscation ain't so easy, so you may rely on a third party library/tool to achieve it. Ironically, most of the tools that obfuscate PHP, are written in PHP as well ! So it won't be difficult to get started with any of these libraries.

In this top, we'll share with you 5 of the most known, functional and easy to use libraries/tools to obfuscate PHP code on small, medium and large projects.

5. Eccenux POBS

POBS is a PHP Obfuscator. This means it "compiles" your PHP files by making them unreadable to a human. This is not meant to be bullet proof. The output code will not be re-usable for most people, but dedicated user will always be able to guess what you are doing in most single functions. In other words – re-using output code is hard, but not impossible. Installing POBS is as easy as I could think of. Just unzip the downloaded file and put it a directory that is located under your web server. POBS is a collection of files in just 1 directory.

Having said all that, the tool works pretty well. The configuration is easy and the maintainer has added some comments, fixed some stuff that was not working for him and that's it. This tool can be used on relatively large project (100+ PHP files, about 10000 lines of code - not counting comments).

4. PHP Compactor

The PHP compactor library will help you tompress and Obfuscate PHP code easily. Do not use this to speed up your PHP by compacting it. I will come for you. Use a real bytecode cache. Instead use this to get an idea of the TRUE size of projects by comparing the actual number of characters required to run that class - without long variable names, comments, or other added "fluff".

3. Yakpro PO

YAK Pro stands for Yet Another Killer Product, a Free and Open Source tool Published under the MIT License. This tool parses php with the best existing php parser PHP-Parser 4.x, which is an awesome php parsing library written by nikic. You just have to download the zip archive and uncompress it under the PHP-Parser subdirectory, or make a git clone. his tool has been written in order to obfuscate pure php sources. it is not intended to be used with html and embeded php inside (use at your own risks...you may try to deactivate statements shuffling...). You can still embed html within php using the echo <<<END ... END; syntax!.

When you have a php project you want to distribute, as php is a script interpretor, you distribute also all the sources of your software. You may want, for any reason, that other people do not understand, modify, or adapt your software. As your software must be understandable by the php runtime, but needs to be very difficult to understand by human people, obfuscation is a very good way to achieve this goal.

2. pH-7 Obfuscator

The ph7 Obfuscator library is a very simple and effective Obfuscator PHP class (this is not a stupid base64 encoding script, but a real and effective obfuscation script). If you want to keep your open source code private, but working on all Web hosting. This Obfuscator class is the obfuscator you need! Not easy readable by developers (unless they are ready to spend lot of time). This will really discourage them. To use this library you will need to run it in PHP 5.2 or higher (works with PHP 7.*+ as well).

1. PHP Obfuscator by Naneu

This is an "obfuscator" for PSR/OOp PHP code. Different from other obfuscators, which often use a (reversible) eval() based obfuscation, this tool actually parses PHP, and obfuscates variable names, methods, etc. This means is can not be reversed by tools such as UnPHP.

This library was written out of the need to obfuscate the source for a private library which for various reasons could not be shared without steps to protect the source from prying eyes. It is not technically feasible to "encrypt" PHP source code, while retaining the option to run it on a standard PHP runtime. Tools such as Zend Guard use run-time plugins, but even these offer no real security. While this tool does not make PHP code impossible to read, it will make it significantly less legible. It is compatible with PHP 5.3, 5.4 and 5.5, but needs PHP 5.4+ to run.

If you know another awesome open source tool/library to obfuscate PHP code, please share it with the community in the comment box.


Senior Software Engineer at Software Medico. Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.

Sponsors