4

I've been searching a way to compile PHP source code and using it in a PHP script by loading the compiled code. No resultat yet, a small try using bcompiler but it's not compiling due to changes on the Zend core API, maybe small parts need to be replaced.

Other try with no success was using phpc, the version recommend for the compiler is PHP 5.2, so the API no longer supports changes to 5.4.

hakre
  • 193,403
  • 52
  • 435
  • 836
hgates
  • 209
  • 5
  • 12
  • 3
    Php isn't compiled. It's a scripting language. Are you trying to identify errors or something? – Steven Leimberg Oct 29 '12 at 23:02
  • @StevenLeimberg PHP certainly can be compiled... https://github.com/facebook/hiphop-php/ http://www.bambalam.se/bamcompile/ http://sourceforge.net/projects/binaryphp/ http://www.roadsend.com/home/index.php?pageID=compiler – batfastad Oct 29 '12 at 23:06
  • 1
    There are a number of compilers for PHP, but the only one I know of that's current is HipHop, written by Facebook. But I think that's targetted at PHP 5.3. – Spudley Oct 29 '12 at 23:07
  • It seems like many of these convert PHP to C++ or similar & then compile that to an exe. Cool. I will definitely look into those links. You learn something new every day. :) – Steven Leimberg Oct 30 '12 at 03:19
  • Try `php-ng`. It's already merged into the master branch and is confirmed to be in PHP 7 (there won't be a PHP 6). Maybe you also like a simple `phar` ? – Daniel W. Feb 19 '15 at 21:17

3 Answers3

1

Roadsend Raven might be an alternative to phpc

Mark Baker
  • 209,507
  • 32
  • 346
  • 385
1

I believe Facebook Hiphop's function is to compile PHP into C++ so it might be worth checking out... https://github.com/facebook/hiphop-php/

batfastad
  • 1,943
  • 3
  • 27
  • 37
  • hiphop is good when using simple function/class with no extra dependencies ? – hgates Oct 29 '12 at 23:18
  • how about handling php code using thirs party library, soap module, xml module, ldap module ect... not sure hiphop handle that kind of needs – hgates Oct 29 '12 at 23:20
  • I've never used it myself I'm afraid so that's something you'll have to look at. This might get you some more info... https://github.com/facebook/hiphop-php/wiki/Running-HipHop and here's some other compilers... http://stackoverflow.com/a/1408499/295924 – batfastad Oct 29 '12 at 23:33
1

bcompiler works up to PHP 5.3. I'm currently using it and I can't upgrade to PHP 5.4 now because it isn't supported.

Here is the patch to get it working on Ubuntu 12.04 with the Suhosin patch.

Destraht
  • 26
  • 1