Can I encrypt PHP source or compile it so others can't see it? and how?

I need to encrypt some PHP source that I've released to the public.

Is this possible? Can PHP be "compiled" ?


You can buy Zend Guard to encode your PHP sources, and then use the Zend Optimizer to run it. There is an opensource/free PHP compiler project as well (bcompiler, and also take a look to this) but I never used it because at the time I needed it the project was still incomplete.


You can have a look at phc which can generate executables from PHP. It also has some other options to create C-code, XML, optimized PHP, etc. from the original PHP source.


since they need to run on a wide range of boxes, some of which don't have access to install things like Zend Optimizer and PHP Express Loader

If you need your code to be able to run on a standard version of PHP without any modules then the answer is NO. There is no method of compilation that is going to work on the wide variety of different PHP installations.


Nusphere (the makers of PhpED) have a product called Nu-coder for doing exactly this. Although not free, it will do what you want.