PHP code doesn't really get compiled as you would compile a C++ program, for example. Rather the code is executed by your web server client when someone accesses the php page. I don't know the technical term for what it's called ... but you need a web server such as Apache (comes with most linux distributions otherwise www.apache.org ) that can server your php scripts to clients connecting to it.
cscgal
The Queen of DaniWeb
19,421 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
A free alternative to Zend is Turck mmCache. According to their website:
Turck MMCache is a free open source PHP accelerator, optimizer, encoder and dynamic content cache for PHP. It increases performance of PHP scripts by caching them in compiled state, so that the overhead of compiling is almost completely eliminated. Also it uses some optimizations to speed up execution of PHP scripts. Turck MMCache typically reduces server load and increases the speed of your PHP code by 1-10 times.
To be perfectly honest, Daniweb has always used mmCache :)
cscgal
The Queen of DaniWeb
19,421 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
I don't actually think this is possible.
And everyone, PHP is never compiled. It is a scripting language; therefore it is interpreted (at runtime). A web language like ASP.NET is fully compiled (at the page's first view or at design time into a managed dll file).
Tekmaven
Software Architect
1,274 posts since Feb 2002
Reputation Points: 322
Solved Threads: 28
OK - Turck mmCache is software which compiles php code to lessen the server load (by as much as 500 to 1000%) when the code is interpreted at run time. There is software such as that that cyberwisdom mentioned which can be used to encode php files so that the php code itself can be distributed. Note that when you put php files on the web, and someone loads a .php page, there is absolutely no way for them to determine or get the php code that was used to build the page.
cscgal
The Queen of DaniWeb
19,421 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
It is possible to compile PHP code into a standalone application. I've seen a media-database that was written in PHP, but all I had to to is run an EXE file.
I googled a bit and this is what I found:
--quote from website http://www.roadsend.com/home/index.php?SMC=1&pageID=compiler --
Compile Stand Alone Applications
PCC allows you to compile your PHP source into stand alone applications. No interpreter is required. Your source is compiled into an optimized machine executable program. The program is distributable with or without the source code and cannot be decompiled back into it's original PHP source. Distribution (or sale) of your compiled programs is royalty free.
Yes, I've heard of this, but it doesn't make sense to start an application from scratch using PHP. I guess if you already had plenty of code, APIs and what not that you wanted to reuse, you could utilize PHP. However, It doesn't make sense to me creating a server or a desktop application using a language that was designed for the web.
samaru
a.k.a inscissor
1,256 posts since Feb 2002
Reputation Points: 262
Solved Threads: 18
I agree that it doesn't make that much sence, but the question was if it was possible to compile PHP.
Yup, I know. I was only throwing in my two cents on how I thought it didn't make much sense. I know that almost nothing is impossible because I'm always surprised that someone, somewhere, has done it.
samaru
a.k.a inscissor
1,256 posts since Feb 2002
Reputation Points: 262
Solved Threads: 18
In an extreme situation, where it was an emergency and I had plenty of PHP libraries in store, did not know another language as well, and performance was not an issue, then yes, I would use PHP. Otherwise I would go with C/VC++.
samaru
a.k.a inscissor
1,256 posts since Feb 2002
Reputation Points: 262
Solved Threads: 18