tags:

views:

730

answers:

3

I know php scripts don't actually compile until they are run. However say I want to create a small simple program and compile it to a binary without requiring the php binary. How could I do this?

I'v seen a few IDE's out there that would do this, but either they are all for windows or the linux versions don't actually build properly.
What I would like is something like py2exe that does it in the script itself.

+3  A: 

There is this: http://www.bambalam.se/bamcompile/ but that compiles to Windows bytecode. There are a few others, but all I have seen will compile for windows only.

Few More:
http://www.nusphere.com/products/phpdock.htm

Edit: I almost forgot if your looking to make it work on linux without regard for windows you can just add

#!/usr/bin/php

to the top of the script and you should be able to run it from the command line. Don't forget to chmod +x the file first.

Unkwntech
+6  A: 

Check out phc: the PHP compiler

If you just want to run it like a script, you may not need to compile it per say, but just run it via the command line. Read running PHP via the command line.

Chris Bartow
"per se" please. I see this mistake more and more often: http://en.wiktionary.org/wiki/per_se
lImbus
A: 

Have a look at Facebook's Hiphop-PHP. It's able to convert PHP code into C++ then compile it with g++. Apparently, they've even gotten it to successfully compile entire WordPress installations.

Gabriel Evans