In this first tutorial, we’ll see how to get started with the Encoder, and how to encode your files using basic settings.

Note: This tutorial uses features that were added in version 8.2 of the Encoder. If you are using an older version, we would recommend updating before continuing.

Create Sample Code

The first thing we need is some PHP to encode. Create a new folder somewhere on your system, and make a note of where you created it. Inside this folder, create a new PHP file, and add the following code (or add some sample code of your own):

<?php

echo "<html><body>This is a test for the ionCube PHP Encoder!<br  />";

$agent = $_SERVER['HTTP_USER_AGENT'];
echo "Your User Agent is: " . $agent . "<br  />";

echo "And now, for no reason, here's all the prime numbers from 1 to 1000!<br  />";
$primes = array();
array_push($primes, 2);
for ($i = 3; $i <= 1000; $i += 2)
{
    $isPrime = true;
    for ($j = 0; $j < sizeof($primes); ++$j)
    {
        if ($i % $primes[$j] === 0)
        {
            $isPrime = false;
            break;
        }
    }
    if ($isPrime === true) array_push($primes, $i);
}

foreach ($primes as $prime) echo $prime . " ";

echo "</body></html>";
?>

 

 

Setting up Your Project

When you first open the Encoder, the first thing you will need to do is create a new project. There are plenty of ways to do this. New projects can be made from the startup panel, the toolbar or from the File menu.

1-11-2
Once you have created a new project, the “Project Settings” window will be displayed.

 

2

 

The quickstart panel is designed to make setting up a project as quickly as possible, and contains all of the required settings to start encoding. Each of the settings are covered in the same order as they appear in the GUI.

First, you will need to tell the Encoder where the PHP files you want to encode are located, so browse for the folder containing the PHP file you created earlier. As a side note, you may notice your files appear on the source panel in the “Project files” tree structure.

Next, you will need to specify where your encoded files will be placed once they have finished processing. First, specify a name for the folder where your Encoded files will be placed, placing this in the “Target folder name” textbox. Then, browse for the location where you want this folder to be created.

Note: The Encoder has checks in place that will ensure your unencoded files are never overwritten. This is to prevent you from losing your original source code.

After this, you can choose which type of Encoder you wish to use to encode your files. This is mainly for users who are unable to update their loaders to the latest versions. For now, this can be left set to “Current”.

Finally, below this, you can specify the minimum version of PHP that is required on the server to be able to run your Encoded files and which has the language features you are using. So, if you are using PHP 5.3 language features such as namespaces then you will need to select either PHP 5.3 or PHP 5.4. By default, the source language is set to PHP 5, but this can be changed. Ideally, you will want to target the highest possible value for your server, i.e. If your server is running PHP 5.4, choose PHP 5.4.

Once your settings have been filled in, this page should look similar to this:

 

3

 

Once this has been done, click the OK button at the bottom of the Settings page. You may notice a bar move at the bottom of the Encoder. This is the “Security Checklist”, which will be described in greater detail in a future tutorial, but for now it can be ignored.

Now would be a good time to save your project, so choose any of the save options available:

 

4-14-2
You will also notice that your project file has been added to the side of the startup panel. This is useful if you want to quickly open this project again later on.

Encoding your Files

Now that all of the previous steps have been fulfilled, the project should be ready to encode. So choose any of the following methods to begin encoding the PHP file:

 

5-1 5-2
Once it’s done, you should get the following results:

 

6

 

Congratulations!

Your sample PHP file has now been encoded. If you look in the directory you created in the “Target” settings tab, you will see an encoded PHP file inside. This file, when run on a server with the Loader correctly installed, will function in the same way as the original.

Using the ionCube Encoder GUI: Getting Started
twitterlinkedinmail
Tagged on: