Encoding application sources is a common practice when it comes to protecting and/or licensing your application source code. Today we’ll talk about ionCube - one of the most popular and widely used solutions to prevent unauthorized use. Being PHP-oriented, ionCube provides two correlated tools – Encoder to compile PHP files into bytecode and Loader, which handles execution of such encoded files.
Whilst encoding shouldn’t be a big problem for the majority of developers, running such protected application can become a real point of concern for an average user, since often it requires the involvement of some auxiliary modules and libraries. Thus, to enable executing secured PHP source code without struggling on manual server configurations, the Jelastic Cloud provides dedicated lightweight ionCube Loader add-on for one-click installation.
So, log in to the Jelastic dashboard with your credentials and follow the instruction how to start operating encoded scripts in a matter of minutes.
ionCube Loader Add-On Installation
1. First of all, let’s ensure you have a proper PHP environment for processing your protected code with ionCube Loader.
For that, launch the environment topology wizard (by clicking either New Environment button at the dashboard top or Change environment topology icon next to the existing one) and switch to PHP tab.
Here, application server choice depends only on your preferences (since both Apache and NGINX are supported), whilst a little more attention should be paid to the PHP versions list.
When selecting a particular engine, you need to consider it’s compatibility with ionCube Encoder version your scripts were initially converted with. As a general rule of thumb, encoded files could be processed on PHP versions that are equal to and higher than the source Encoder language, i.e. the full backward compatibility is provided. However, there are a few exceptions here:
- currently, PHP 7.1 is not supported
- with PHP 7.0 engine, only PHP 5.6-based files can be decoded
- with PHP 5.6 and PHP 5.5, scripts of PHP 4 version can’t be decoded
To confirm the set parameters, click on Create or Apply (depending on whether you’ve created a new environment or adjusted the existing one).
2. Now, enter Jelastic Marketplace and switch to the section with pluggable Add-ons.
Use search box to locate the one-click ionCube package and click Install.
3. In the opened installation window, specify the following details:
- Environment name - environment the ionCube tool should be integrated to (encoded-app, in our case)
- Nodes - target PHP application server for the add-on appliance (is fetched automatically upon selecting the environment)
Proceed with clicking on Install and wait a minute till this process is completed (you’ll also receive the appropriate email notification).
Now, let’s check that the add-on is up and running properly.
Verification with ionCube Loader Wizard
The simplest way to ensure ionCube was successfully integrated is to review the php_info() server output - information on its status and version is listed in a separate block just under the main server configuration stats.
For more comprehensive check-up, you can launch a dedicated ionCube Loader Wizard within the appropriate container. It will test the proper Loader operability and provide you with a guidance in case any issue is detected. This step is optional and does not affect the actual ionCube operability. Thus, if you consider the additional check is needed, follow the instructions below:
1. Upload this archive via the Deployment Manager and initiate its deployment by selecting the destination environment (e.g. encoded-app).
2. In the opened dialog, type some custom context to run the wizard at (so that it won’t intersect your main app location - e.g. ioncube) and click Deploy.
3. When the project is deployed, click Open in browser next to it.
4. To launch the Wizard itself, append loader-wizard.php to the end of the opened tab URL.
It will analyze and output the current ionCube add-on status, including the appropriate Loader version and PHP engine it runs at.
5. For security reasons, it’s highly recommended to Delete the Wizard when it is no longer required - simply remove the server context it was handled at.
That’s it! Finally, let’s consider how to put the Loader add-on into action with the files that require decoding.
Running Encoded Application with ionCube
As a base for our encoded app example, we’ll use the default Jelastic Hello World project - take a quick look at a code snippet from its index.php file during conversion:
- before encoding
- after encoding
The compiled code contains several layers of encoding that can be interpreted and processed only by ionCube Loader. This will be done automatically by the extension we’ve installed - just deploy your PHP project to the destination environment as usual and Open it in browser.
The application is up and running, so it means the Loader has successfully processed all protected files.
At this point, with the required application structure being already deployed inside a container, your ionCube Loader performance can be additionally increased through eliminating from the unrequired files’ processing.
Restricting ionCube Work Area
With default settings, the Loader will examine all the files on a web server for being encoded and process the necessary ones when the appropriate application is launched. In order to accelerate this process and boost decoding performance, it’s a good practice to point Loader to the server location with your encoded files (or directly to the required ones).
Since ionCube Loader represents a PHP extension, its settings can be adjusted within the php.ini configuration file at your application server. To access it, click Config next to the appropriate node and select this file in the File manager panel.
At the very end of the opened file, specify the ioncube.loader.encoded_paths directive with a path to the required destination directory or files as its value, e.g.:
ioncube.loader.encoded_paths = "/var/www/webroot/ROOT/index.php"
Do not forget to Save the changes and be sure your data is safe now.
Host your applications with no compromise to security! Try out ionCube Loader for running PHP encoded files in Jelastic Cloud at one of the hosting providers.