1

Currently PHP 5.3 hosting environments have to install and use "Zend Guard Loader" extension to process and execute Zend Guard encoded files. I was unable to make it execute files that were encoded for use with Zend Optimizer (PHP 5.2).

Any workaround for this?

hakre
  • 193,403
  • 52
  • 435
  • 836

3 Answers3

0

I don't think so... I am also stuck with using php 5.2 because of that.

If you want to run zend encoded 5.2 scripts using "Zend Guard Loader", you will need to fork out more money and buy the new version to encode the scripts again.... sad.

iWantSimpleLife
  • 1,944
  • 14
  • 22
  • Actually I don't have to spend more money, since Zend Guard includes both encoders, and even if i had to - money isn't a problem. Problem is that i have to maintain two versions of encoded files for php 5.2 and 5.3, instead of having just one that will work both under Zend Guard Loader and Zend Optimizer. –  Nov 14 '11 at 03:20
  • No way around it. Cos the 2 product are 100% not compatable. – iWantSimpleLife Nov 14 '11 at 04:14
  • Maybe you can roll your own encoding using the bccompiler extension? (see http://php.net/manual/en/book.bcompiler.php)( – iWantSimpleLife Nov 14 '11 at 04:16
  • Not a viable solution. I'm developing a script I don't want to make a pain to install, by asking users to install this extension on hosting environments (while majority of 5.2 hostings have Zend Optimizer enabled, and many of 5.3 ones have Zend Guard Loader). –  Nov 14 '11 at 04:20
  • Then I guess you are stuck, cos Zend does not want to do this. – iWantSimpleLife Nov 14 '11 at 04:52
  • I'm looking for any ideas, but not the ones involving "you can't do this". The last approach i'd like to implement is to researching encoded file structure to see how it's handled by zend guard loader/zend optimizer to merge two encoded versions that would likely work, but i'm asking if there are any other alternatives. –  Nov 14 '11 at 04:58
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/4964/discussion-between-oleg-maximoff-and-iwantsimplelife) –  Nov 14 '11 at 04:59
0

The only way that worked for me was to include php 5.2 file instead of Zend Guards message that is displayed when no zend guard loader found with if condition checking php version. Dirty, but working, yet 2 files still required to be present, but no need to have loader switching them in unprotected code.

0

To answer the Encoding vs. Runtime in Zend Guard/Optimizer/Loader context - they should perfectly match. The accepted answer is incorrect - there is no tweak to execute PHP 5.3 encoded files in Optimizer loaded in PHP 5.2.

Maintaining 2 target versions is very easy if you script / batch your encoding process when you have code updates. You just execute your source encoding once with zendenc52 and then with zendenc53, giving them different target directories.

More about that. PHP 5.3 code is different from 5.2, and you should actually have 2 different branches for your sources matching those versions. Old News: http://php.net/manual/en/migration53.php

When testing / staging a Zend Guard encoded application, make sure you test the encoded version (and debug the open sources of course as needed). The reason is simple - encoded files have some overhead of data tables which handles obfuscation, and might change PHP functionality with some advanced PHP syntax. If any issue is found in encoded files while testing - it is easy to locate and fix the source. If you test only the source version and then encode and deploy to your customers - result is unpredictable.

As for deployment, when you install/untar/git/svn deploy your PHP files, you can either stick the PHP target version to your releases / downloads / code pushes, so they install in the correct version, or deploy 2 versions in different document root locations, and you can symlink / rewrite to the correct Guarded application version matching the PHP target version 5.2 or 5.3.

Last but not least. The supported runtime for Zend Guard is Zend Server. It has a community edition and anyone can install it free of charge (or purchase licensed components if needed extra boost and monitoring) on supported OSs, via native package managers for DEB / RPM or installation file (Windows, Mac, Other Linuxes not supported with native package managers). Zend Server optional Loader component will handle the encoded application files, and it comes with PHP 5.2 and 5.3 branches, so there is no need to manually install Zend Optimizer or Loader on your PHP. Upgrade from PHP 5.2 to 5.3 is easy and native when applications (encoded and open source) were properly migrated.

Hope this helps.

  • 1
    Your recommendations won't fit my script distribution scheme, where I don't have control over server environment of where my script is installed. And there's a tweak, that yet requires some Zendenc binaries modifications, that allows to have a single file for both zg loader version, yet very unstable. P.S. It seems the only way is to hope servers will start replacing 5.2 with 5.3 soon (with recent stable release of 5.4) –  Mar 13 '12 at 10:26