Lazy PHP

I would say I love this site. It’s a very simple to use and handy but on the other hand, knowledgeable and informative website containing tons of interesting articles, tutorials and forum discussions.

When I was about to start learning PHP and MySQL I was introduced to an article by the name of “Build you own Database Driven Website Using PHP and MySQL”. Now this is the closes thing I can find to that article, which is sample PDF of a book. I believe even this sample is enough to get you started.

All I wanted to say is this site has it all, various resources for all levels.

Today I came across another interesting article about PHP, how it works and how to make its performance better. The article is quite old but still applicable and useful.

It is very useful to know behind the scenes of the technology you’re using. The low-level knowledge of “How things work” will give you better understanding of how to improve you application and how to increase the performance. And the more you know the tools provided, the better and faster you can develop.

The way PHP scripts are being executed and interpreted, gives you an idea of how you can improve the performance. In this article it speaks about the 4 stage execution of each request by WebServer/PHP :

  1. Incoming Request : When WebServer receives the Request for the script
  2. Prepare OPCODEs : When the PHP script is being parsed and OPCODES are being generated.
  3. Execution of script and responding back to user
  4. Trash the lot including all the OPCODEs, variables and etc

We all know that now a days there are several different tools to improve the stages 2 and 4 which are the most resource consuming and duplicated tasks of the PHP Interpreter. PHP Accelerators Like APC , eAccelerator,XCache and so on help a lot to eliminate the phases #2 and #4.

Most PHP accelerators work by caching the compiled bytecode of PHP scripts to avoid the overhead of parsing and compiling source code on each request[1].

Also in this great series of articles “Anonymous functions” known as “Closures” and “Variable Functions” are being discussed and there are some simple but very helpful samples of how they work and how they can help.

Also techniques like ‘Lazy includes’ which seems to be pretty obvious but many of us forget it, have been discussed.

I will let you read the articles by yourself ; Part-1 , Part-2, Part-3 and enjoy it 🙂

[1] :

1. Incoming Request:Incoming Request

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s