How to Protect Your PHP Source Code

Oct 17, 2013, by admin

One of the main threat PHP developers face is that PHP is an interpreted language, means PHP source code is readable by anybody who downloads your application. We can say that it’s a drawback of PHP. But you can protect your intellectual property by encoding your PHP source code. Here in this article I will explain how to protect your PHP source code.

Actually there are many tools available for protecting php code. But here we will discuss ionCude PHP encoder tool. By this tool, you can protect your PHP 4 & 5 source code from easy observation, theft and change. So before releasing your PHP software, you can use the encoder to convert your plain-text PHP files into special encrypted files.

The ionCude PHP Encoder is available for Windows, Linux, FreeBSD and Intel OS X. All versions offer command line access for encoding, and also for creating license files using Pro or Cerberus. This feature is ideal if you wish to automate processing. The Windows Encoder also includes an easy to use GUI, and the Windows Pro and Cerberus editions include a Linux based license generator for PHP scripts too, allowing scripts to be protected using Windows and creating license files from a Linux based web server.

How To Encode PHP source files

Here we will run a php script(phpencoder.php) for encoding its source code.  We will use below command to encode this file.

/usr/local/ioncube/ioncube_encoder5 phpencoder.php -o phpencoder-enc.php

  1. <?php
  2. echo “MY PHP Encoder Example!”;
  3. ?>

You can also Encode an entire project directory by using below command:

/usr/local/ioncube/ioncube_encoder5 projectDir -o build

As There are are many different options available, encoding above script (phpencoder.php) with the default options will return following PHP file.

  1. <?php
  2. echo(‘Site error: the file <b>’.__FILE__.‘</b> requires the ionCube PHP Loader ’.
  3. basename($__ln).‘ to be installed by the site administrator.’);
  4. ?>
  5. 4+oV5BgRgd22U2z7JoK/KmKPIcszhD8pg3hvN+5vc4HFcsGMn/El/4CMYaLFFzaqguLCeb9su8xn
  6. i0+eWxJg/kwNHRkiBvY1aMf1AvwPf14DIwCvegtJC7cbx9cN5jBjwSspVjhVsQnxFx9oBut6R0Kc
  7. V+OLw6XBTNm5sKpbL6DVm2jqk8Wasm9oJgKLZxBtvVBeP5vZrOiod+L7SoplcmTgtyr5wzS3sEzj
  8. r7ixXPUY4H82MyuzZyjYTkSKkz9qlMzWHddrUHJX3y0zPfDqWDUeD1BibJQJ9BXkP7jb4pdKQv/h
  9. sMqhthNQQRSp6nOJHq8oDDYLE+p403GYs2As9qEI2wNAg6j6ln0BRP7shcbNTb5a8O4VjjLhGDwG
  10. 1AYOxaM4R5QneCFr+xYdtEYSep8FW1i9IBzF1FuDa7eMoPDqaQdjTLAPsy5O831yGpAHohx3FzUK
  11. aewZTV+tdru=

The ionCube PHP Encoder is a commercial product, there is a limited time Trial Version available for download.