Page 1 of 2
Can we build PHP 5 Class?
Posted: Fri Jun 15, 2007 7:39 am
by olog-hai
Hi,
I just want to know if it's doable to build or compile php5 class ? Apache 2 can support this ?
Thanks.
Posted: Fri Jun 15, 2007 7:58 am
by volka
Do you want to write an php extension module (not in php itself but maybe C/C++) that exports a php class?
Posted: Fri Jun 15, 2007 8:09 am
by olog-hai
Is it the way to work with php 5 compiled class ?
I've a web site that use PHP 5 class, I want to know if I can compile this class and use them ? it's only for a performance purpose
in other word: Like microsoft .NET, all class is compiled and ISS load these compiled class in memory and work with them.
with PHP5 and Apache 2, can we have this kind of behavior ?
compiled class is really faster than interpreted php file right ?
thanks.
Posted: Fri Jun 15, 2007 9:05 am
by Jenk
In a word: No.
Posted: Fri Jun 15, 2007 10:46 am
by DaveTheAve
I believe I understand where your coming from, you want to know if you can compile your script into machine-code and be interpreted ONCE, instead of wasting precious time interpreting it EVERY run just to get the same effect with more time wasted.
The Answer is:
Yes and No, unlike what you have read above, not saying they're wrong (once they see what I'm talking about they'll agree or research it), but they are forgetting an important extension for PHP. I'm not sure how fimilar you are with Caches (now you ppl know where I'm going?), but there is a little program called APC (
http://us.php.net/apc) that, once a script is first compiled, will save the machine-coded version in a cache for a preset time. Please note however, that doing this has it's "ups and downs", while increasing speed and productivity, it will not work for most dynamic corners of web applications. I suggest you do more research into this program and test it out before going public.
Posted: Fri Jun 15, 2007 11:11 am
by RobertGonzalez
I'll reiterate what Jenk said: No.
PHP is interpreted, .NET is compiled. Big difference, but a difference that has it's goods and bads.
What is your desired for a compiled language framework?
Posted: Fri Jun 15, 2007 11:47 am
by olog-hai
I wanted to know if PHP get a compile mode.
Is PHP is on the way to get a framework in the futur version ? .PHP 6 Framework
thanks.
Posted: Fri Jun 15, 2007 11:55 am
by Benjamin
Search for PHP Framework, either here or on your favorite search engine.
Posted: Fri Jun 15, 2007 11:59 am
by RobertGonzalez
I think as long as PHP is interpreted then no, it won't have a framework like the .NET framework, if that is what you are asking. But can I ask again, what is your desired for a compiled language framework?
Posted: Fri Jun 15, 2007 12:11 pm
by olog-hai
I have no desire for compiled language framework, but I've desire for my wife

.
My first goal is to get my web site faster, and I always heard that compiled language is faster than interpreted. So it was my question.
and you, do you have preference and why ?
thanks.
Posted: Fri Jun 15, 2007 12:22 pm
by alex.barylski
There are ways of compiling PHP into a byte-code so it executes at speeds equivelant to ASP.NET however neither will come close to a well tuned nativley compiled C application.
Writing CGI using plain vanilla C is a *lot* of work thats why most just stick to Perl or PHP. Unless the speed increase is really needed the etrax effort isn't worth it.
There is however a PHP compiler, which does something similar to a native C compiler.
Google for Roadsend you'll find there.

Posted: Fri Jun 15, 2007 12:39 pm
by Chris Corbyn
If your web site is slow then the overhead of compiling the PHP code is not going to make any noticable difference. We're talking about milliseconds here. Sounds like you need to optimize your PHP code before doing anything else

Posted: Fri Jun 15, 2007 12:48 pm
by RobertGonzalez
Seriously, PHP interprests very quickly. In many cases, .NET apps run at the same speed as PHP apps run when the servers (web, file, database, etc) are all configured properly AND the code used in the app is optimized correctly. Overall speed differences are negligible when it comes to performance. In my opinion.
Posted: Fri Jun 15, 2007 3:18 pm
by Christopher
olog-hai wrote:My first goal is to get my web site faster
Is your website actually slow?
If it is, have you tried the 1000s of things you could do to speed it up?
olog-hai wrote:I always heard that compiled language is faster than interpreted. So it was my question.
You always heard wrong.
Posted: Fri Jun 15, 2007 5:20 pm
by Ambush Commander
You need to profile your application and start wood-shedding the parts that are slow.
But to answer your question, you can cache PHP's "opcodes" using
APC.