-3

I have my own PHP CLI utility, so I have a need in PHP compiler. I found nothing working with the last PHP versions, so I'm using a Phalanger now, but it's requires it installed on client mashine to run compiled scripts (!), and it's compiles files in .NET (!!). It's worth crutch I've ever seen, but it's working and have a console version (because I'm using Notepad++ for development). I don't know why only worth crutch is working) So, that I stays searching for the good console PHP compiler all time, but found nothing at this time. All what I found is extremely old. There's a list and year of last release:

  • phc: 2011
  • Roadsend PHP Compiler: 2010
  • Bambalam: 2006
  • BinaryPHP: 2003 (!)

There's a HipHop released by FB, but it's so monstrous to use it, and it's only looks like a virtual mashine, not compiler in fact I think. So finally I've decided to write my own compiler to work with new versions of PHP and use a native bcompiler to get a bytecode, but find out, that a bcompiler is dead too, its last release was at 2011! So can I ask you, why all PHP comilers are dead? There's no problem to find a bcompiler sourses, build a new DLL extention for PHP for Windows for example, and put the actual PHP DLL version with it, but why in times, when the amazing PHP 7 was released, there's no any (any!) lightweight and simple actual PHP compilers?

Or I don't understand something? If it so - what? Thanks a lot!

Acuna
  • 1,741
  • 17
  • 20
  • You didn't mention WHY you "need" a compiler. Speed? To protect your code? – Danial Nov 04 '16 at 21:49
  • Ah yes, I want to protect my code and split PHP-files into one .EXE – Acuna Nov 05 '16 at 05:04
  • One answer is that nobody wants to pay for them, and it is hard to build one that really works one real applications. They are worse to maintain because PHP evolves so fast. – Ira Baxter Nov 06 '16 at 00:40
  • Ira, sorry, but almost all of compilers (which I've listed in my question for example) are free. But second reason is correct I think ;) – Acuna Nov 21 '16 at 20:33

3 Answers3

0

It's a big project that never ends, because php is evolving and growing (unlike a language like C). Open source maintainers move on to other things, like spending time with their family, or getting a job.

I think the projects died because they generally didn't work for real life projects. At best you could compile a few scripts, but most would fail at some point with a big project. For web development, which I suspect is 98% of the applications, you have embedded scripts and styles that just aren't compatible with compiling. So you have to write code differently to use a compiler, which in some ways defeats the purpose of using PHP in the first place.

There are so many versions of PHP the compilers were also so far behind to be rendered useless. You really have to come up with another way to protect your product. There's a decoder for every commercial encoder, so there's really no way to protect your code from someone who wants to get it. I use ioncube to encode my scripts but that's just to keep customers from breaking things and then complaining that it doesnt work.

Danial
  • 1,496
  • 14
  • 15
  • Danial sums up opensource development and the challenges in this space very well. Zend recently abandoned their Encoder as supporting PHP 7 was hard, and like most solutions, never supported running old encoded files on newer PHP. ionCube always has, but it's a big undertaking to achieve. Innovating the security is essential and also requires much work. Features such as Dynamic Keys in ionCube 9 are highly effective at defeating current decoding sites as decryption keys are not stored anywhere, but the development effort was large. Disclosure: I am associated with ionCube. – Nick Nov 08 '16 at 13:29
  • Thanks for your answer and sorry for my long answer to you, guys) Okay, I understand you. Well, in a fact, I understand, that most encoders will be encobed simple, but I want a "fools security". – Acuna Nov 21 '16 at 20:24
  • And can I ask you, are differ versions of PHP have an differ bytecode? Excepts PHP 7 of course. Because I use only [], not array (), consctructions for create a new arrays, and preg_replace_callback () instead or /r modifier in regular expressions, so is there's a possibility to create a compiler for 5.6 or more like this? If it's not differ, I think I can try to apply some of my thoughts to check if it have a rights to life) – Acuna Nov 21 '16 at 20:30
  • What do you mean by "fools security"? There's no such thing as a php compiler. The so-called compilers generate byte code, which are just tokens that if you spend enough time on it, can be used to generate the original code. There is no way to secure your php code completely. What you can do is make it very time consuming to reverse engineer it. – Danial Dec 11 '16 at 00:34
  • Sorry, have lost your answer. By "fools security" I mean simply encoding the code, which can't seen by quick look, but of course it'll be decoded before the app start to work with it. But now looking I'm for possibility to compile it to the bytecode with OPCache for example. Of course it'll be decompiled, but it's task isn't trivial by ordinary users. Do you know is it really in theory? – Acuna May 13 '17 at 00:50
  • Whether you compile it to bytecode or not, it still has to be reassembled to source at some point, so it can be reverse engineered with enough effort. ANY PHP encoder can be reverse engineered. While commercial encryptors are more secure, there are also companies dedicated to breaking them, so IMO, they are less secure. Write your own, embed it in the PHP source code, and make it as complicated to figure out as possible. – Danial Jun 21 '17 at 00:54
0

After a while looking for solution I've wrote my own compiler, which supports PHP 7.1+ (!). So my problem is solved. Thanks to everybody!

Here is it: https://sourceforge.net/projects/phpc/

Acuna
  • 1,741
  • 17
  • 20
0

For compiling very simple (one-file) tools, there's PHPFlexer: http://www.softpedia.com/get/Programming/Debuggers-Decompilers-Dissasemblers/PHPFlexer.shtml

(It's based on phc-win but easier to use)

dkellner
  • 8,726
  • 2
  • 49
  • 47