12

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.

0

3 Answers 3

9

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.

Sign up to request clarification or add additional context in comments.

1 Comment

"per se" please. I see this mistake more and more often: en.wiktionary.org/wiki/per_se
4

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.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.