Protecting Your PHP Source Code With ionCube Encoder
Encoding Your PHP Files
The ionCube PHP Encoder is a command-line script you run either one or more files, or on an entire set of folders. If you're encoding an entire PHP application you would typically run it on the original source folder. The encoder will duplicate the entire tree, except the PHP code will be encoded.
In the previous section I showed you what the encoded PHP code from a basic "Hello World" script looks like. The command I used to generate this encoded script is as shown in Listing 3.
/usr/local/ioncube/ioncube_encoder5 helloworld.php -o helloworld-enc.php
In this example, the
-o specified the output location. In this example I just created the encoded file in the same directory with a different filename. Typically you would want to create the file with the same filename as the original (without replacing the original source code).
To achieve this, set the input and output both to be a directory. The encoder will automatically recurse through all directories in the input directory and encode all PHP files.
To demonstrate this, let's assume
helloworld.php is in a directory called
src. Listing 4 shows the command we use to encode this entire path. The example outputs the encoded files to the
/usr/local/ioncube/ioncube_encoder5 src -o build
We now have a directory called
build which is identical to
src except that the PHP files are encoded.
There are many other command-line options. You can discover some of these by running
ioncube_encoder5 with no arguments. Additionally, the "Encoder User Guide API" document (available from here) is extremely useful.