Reputation: 1208
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've 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.
Upvotes: 12
Views: 17322
Reputation: 15111
Check out phc: the PHP compiler
If you just want to run it like a script, you may not need to compile it per se, but just run it via the command line. Read running PHP via the command line.
Upvotes: 9
Reputation: 772
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.
Upvotes: 0
Reputation: 90851
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.
Upvotes: 4