Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Learn PHP
<Using Nu-Coder's License ManagerDeploying Encoded PHP files with NuSphere PhpDock>
Last updated: Thu, 18 Nov 2010

Deploying Encoded PHP files with NuSphere PhpExpress

Overview of NuSphere PhpExpress

PHP files encoded with NuSphere Nu-Coder require special loader present in PHP interpreter. PhpExpress is NuSphere Free PHP loader and accelerator that provides support for encoded files and also speeds up the execution of regular PHP files.

PhpExress extensions for all operating systems can be found in the folder "loader" of your Nu-Coder installation.

PhpExpress can be downloaded from NuSphere website and distributed Free Of Charge without limitations. Every Nu-Coder installation also comes with PhpExpress. This is how PhpExpress works:
  • When PHP interpreter executes any PHP script it first compiles the script into bytecodes. However Nu-Coder produces PHP files that have been already compiled into bytecodes.
  • PhpExpress loads encoded PHP scripts directly into PHP engine saving time and boosting performance of PHP interpretor
  • PhpExpress checks for license file if required - either via API call in the script to pelm_is_licensed() function (described later in this manual) or -licfile encoding option
  • PhpExpress also implements caching for PHP engine and accelerates execution process even if PHP Script is not encoded

How to deploy NuSphere PhpExpress

NuSphere PhpExpress is a regular PHP extension, which makes it easy to install and deploy. To install PhpExpress:
  • Open php.ini file for editing
  • Add line extension=phpexpress-php-x.x.dll if you are deploying on Windows, extension=phpexpress-php-x.x.so if you are deploying on Unix, Linux or Mac OS operating systems
  • Copy phpexpress-php-x.x.dll or phpexpress-php-x.x.so in the PHP extensions directory specified in php.ini file
  • Stop and Start Apache if you are running PHP as Apache module
  • Execute call to phpinfo() function and make sure that PhpExpress is properly installed
Once PhpExpress is installed on the server, you can execute PHP Scripts encoded with Nu-Coder as well as regular, not encoded PHP scripts. In both cases you will gain an improved performance in the execution of the scripts.

How to use PhpExpress's API with Nu-Coder

PhpExpress provides a number of PHP Functions useful when encoding PHP files with and without Nu-Coder's License Manager.

The following functions are likely to be used by the users deploying files encoded with PHP Enoder:

void phpexpress()
shows phpexpress info page.

array phpexpress_hostid()
returns the list of host IDs that identify server hardware.
Note: all host IDs are shown on the PhpExpress info page. It's recommended to use ALL host IDs that are found on the system. It will make license less sensitive to the hardware changes.

The following functions are likely to be used by PHP developers deploying their PHP applications encoded by Nu-Coder:

bool pelm_is_licensed()
returns true if caller script is protected with license

bool pelm_load_license(string filename)
loads license and returns true if file is found.
Note: if relative path name is specified, PhpExpress will use include_path php setting to find the file. For further details about include_path see php manual.

string pelm_license_filename()
returns license filename that is applied to the caller script. It returns false if no license is used.

string pelm_get_attribute(string attr_name)
reads attribute value from the license applied to the caller script. It returns false if no license is used.

void pe_handle_error($errcode, $errmessage, $licfilename)
gets called if the license is not found, expired or not valid for any other reason.

Possible error codes are:

PE_ERR_NO_LIC - no licenses found
PE_ERR_NO_VALID_LIC - the license is found but it is not applicable for this application
PE_ERR_EXPIRED_LIC - license is expired
PE_ERR_HOST_MISMATCH_LIC - license doesn't match the host (by IP or HTTP host)
PE_ERR_HW_MISMATCH_LIC - license is generated for a different hostid

How to monitor PHP Cache implemented by NuSphere PhpExpress

How to monitor PHP Cache implemented by NuSphere PhpExpress
PhpExpress accelerates execution of PHP scripts by caching them and avoiding unnecessary compilation. You can view and control PHP Cache created by PhpExpress with a single function call to the PHP function phpexpress() provided by PhpExpress PHP extension. phpexpress() produces the output similar to phpinfo() with the user Interface to administer PhpExpress cache. The output of phpexpress() is illustrated here:

Please note that PHP caching is only enabled when PHP is running as an extension of the Web Server - dll on windows or shared object on Linux/Unix/Mac Operating Systems. Caching of PHP scripts when PHP is running in CGI mode is not useful and therefore disabled.

How to load license

PHP scripts protected by the license will only run if the corresponding valid license file is loaded. You can load the License in one of the following ways:
  • Load license in php.ini file using the instruction:
    phpexpress.add_license = license1.txt, license2.txt
  • This instruction is applicable to each virtual host, therefore different virtual hosts can use different licenses.
  • Load license in .htdocs file using the instruction (will only work with php module of Apache):
    php_value phpexpress.add_license "license3.txt"
  • In a file not protected by the license call the function pelm_load_license("license4.txt"). While the file containing this call can not be license protected it can still be encoded. pelm_load_license() function is a part of PhpExpress API
  • Specify the name of the license file at the time of the encoding. For example:
    nu-coder -k longkeyword --licfile lic5.txt file1.php ../encoded/file1.php
    This name can also be entered using EncoderGUI Settings->Protection->Autoload license in Protection Tab
Please note that if the relative path to the file is used, the system will search for the file in all directories listed in include_path.

How to handle expired or invalid license

If the license used for encryption of PHP files is not found or has expired or became invalid in any way, the system will attempt to call the function pe_handle_error($errcode, $errmessage, $licfilename).

To handle the error of invalid license you should implement this function in a file not protected with the license, so it could be executed in this case and provide suitable information to the user (e.g. “Your Trial has Expired”). For example, you can encode error handler with the following parameters:

--eh ./errorhandler.php

Note: For these and other API functions used to work with License Manager please see this section.

<Using Nu-Coder's License ManagerDeploying Encoded PHP files with NuSphere PhpDock>
Last updated: Thu, 18 Nov 2010