One of the issues PHP developers face is that PHP is an interpreted language, meaning PHP source code is readable by anybody who downloads your applications. In this article I will show you how to protect your intellectual property by encoding your PHP source code.
The tool we are going to use to protect our code is ionCube PHP Encoder. Before releasing your PHP software, you use the encoder to convert your plain-text PHP files into special encrypted files.
Because your PHP is encoded into a special byte-code (as opposed to just being obfuscated), a loader must be installed on your web server. A loader is a PHP module that must be installed.
On the ionCube website there is a loaders page which contains the latest versions of the loader for all supported platforms (you must install the correct loader for your platform).
Before we proceed, let's take a quick look at an encoded file. Listing 1 shows a basic PHP script.
echo "Hello, world!\n";
We can then run this script through the encoder. While there are many different options available, encoding a script with the default options yields the following PHP file.
echo('Site error: the file <b>'.__FILE__.'</b> requires the ionCube PHP Loader '.
basename($__ln).' to be installed by the site administrator.');exit(199);
While you cannot understand what this code does just by looking at it, your PHP installation with the correct loader installed interprets this just as if it was the code in Listing 1.