Translate: 
EnglishFrenchGermanItalianPolishPortugueseRussianSpanish

Drupal HH7 project: HipHop for PHP and Drupal 7.4 compatibility patch

June 30th, 2011

Another month, another Drupal 7 version. Drupal 7.4 was released some days ago so it’s my turn to announce the next version of Drupal 7.x patch adding support for HipHop for PHP source code transformer.

Drupal HH7 Version: 1.2
Release date: 30-06-2011
Compatible with: Drupal 7.4
Not compatible with: HipHop branches 36a16fb and 6044908 and Drupal 7.0-7.2
Tested on HipHop branch: 806ee06 and earlier

Modules compatibility list can be found at the end of this article. Please report any patch issues in the comments to this annoucement. Read the rest of this entry »

phpMultiServer, a high-performance HTTP server written in pure PHP

June 14th, 2011

This is a sample, high-performance HTTP server written in pure PHP.

Thanks to various optimizations, this server is able to handle more than 800 HTTP requests/second on a dual core laptop (Core 2 Duo 1.6Ghz).

This in turn allows you to create highly efficient PHP scripts with low response times (less than 1ms latency between sending request to launching PHP script).

In result this software is sometimes faster than the Apache HTTP Server (which is written in highly efficient C language). Read the rest of this entry »

Eval() counterparts in PHP: how to do something wrong faster?

June 13th, 2011

Probably all PHP developers know what is the eval() command, and why it should be avoided.

There are several reasons, but mainly the problem is the safety and efficiency of the script. An additional disadvantage may be lack of support by the compilers of PHP code (for example, HipHop for PHP).

Unfortunately, there are situations where it is necessary to execute dynamically created code. In this article I will focus on performance and faster replacement of eval() command. Read the rest of this entry »

Download VMware image of Fedora 14 Linux with HipHop for PHP installed

June 10th, 2011

Many articles on this blog describes the performance and functionality of HipHop. Since many readers like the dry facts, I decided that I prepare an image of Linux distribution, which will have a built-in support to PHP code translator. Read the rest of this entry »

Running PHP on NFS: huge performance problems and one simple solution.

June 2nd, 2011

Drupal, Joomla and other popular PHP scripts use a PHP language constructs called include_once() and require_once(). This constructs includes other PHP files, but only once. In order to do so, it differentiates between files with their full path using the lstat system call.

Unfortunately this leads to a lot of lstat calls which are not cached using NFS. This in turn can slow down larger PHP applications even tenfold. Read the rest of this entry »

Drupal HH7 project: HipHop for PHP and Drupal 7.2 compatibility patch

May 31st, 2011

Drupal 7.2 was released about five days ago. Today, I’m proud to announce the next version of Drupal 7.x patch adding support for HipHop for PHP source code transformer.

Drupal HH7 Version: 1.1
Release date: 30-05-2011
Compatible with: Drupal 7.2
Not compatible with: HipHop branches 36a16fb and 6044908 and Drupal 7.0-7.1
Tested on HipHop branch: 806ee06 and earlier

Modules compatibility list can be found at the end of this article. Please report any patch issues in the comments to this annoucement. Read the rest of this entry »

Drupal 7: Download HipHop for PHP’s compatible source codes!

May 19th, 2011

As promised in a previous article I give you source codes of Drupal 7 which are compatible with HipHop for PHP source code transformer.

This version of the patch has been successfully tested on a minimum base installation of Drupal 7.0. At the moment I can not guarantee the correct operation of other versions of Drupal. Subsequent patches will add support for additional modules should they prove to be defective during the futher test process.

There is also a new version of patch which is compatible with Drupal 7.2, read this article for futher info.

Please report any patch issues in the comments to this story. Read the rest of this entry »

Drupal 7: HipHop for PHP vs APC – benchmark

May 17th, 2011

Drupal is one of two most popular content management systems (CMS) written in PHP . It is used as a back-end system for at least 1.5% of all websites worldwide. It is also one with the the slowest systems of this kind on the Internet

There have been many suggestions on improving Drupal performance, some of them recommend the use of APC module, data caching, or even compilation of the entire system through HipHop for PHP. While the first two solutions have been successfully implemented, no one was able to perform the build process.

After many battles with the compiler and the Drupal code, I present you results of the first successful translation of Drupal 7 to C++ language. Read the rest of this entry »

Object-Oriented PHP: Implementation of C# getters and setters in PHP

May 13th, 2011

PHP 5 and C# .NET have a getter and setter method feature, making it look like we’re accessing the data member directly. As you probably know, in C# you can define getters and setters for the properties of an object like this:

public class Person
{
    //default constructor 
    public Person()
    {
    }
 
    private string _Name;
    public string Name
    {
        //set the person name
        set { this._Name = value; }
        //get the person name 
        get { return this._Name; }
    }
}

You can simulate this functionality in PHP 5.x using the magic __get () and __set () functions, but that solution has one big drawback. Magic variables are not visible in the PHP code (in a class declaration), and in IDE applications (until the variable is declared “virtually” from the phpDoc comments).

Because of that I present you another little-known functionality of the PHP language, which solves the above problems. In my solution you can easily convert class properties into magic variables which will be visible everywhere in the code/IDE applications. Read the rest of this entry »

How to calculate CPU usage of a PHP script

May 13th, 2011

There are many PHP scripts that calculate it’s execution time, memory usage and even the number of queries sent to databases.

All of these indicators are extremely important when testing the code to optimize it later. For me, however, there is still one parameter missing: the percentage of time the processor spends on execution of the PHP script itself! Read the rest of this entry »

Code injection – a simple PHP virus carried in a JPEG image

May 13th, 2011

As a developer and administrator for the webhosting company I saw many galleries and download scripts written in PHP. While the scripts were generally similar (used file_get_contents(), fopen(), readfile()), sometimes I’ve seen other, less traditional implementations.

A case of one of my company’s customers inspired me to write this article. Few months ago he reported to me with the problem of sending files via a PHP script. Some of his files were sent successfully but others did not and he could not get to the heart of the matter.

After a brief code inspection, it turned out that script written by him had some undesired, additional functionality. Because he’s been using include() clause to read an images, his script was vulnerable to the code injection! Read the rest of this entry »

HipHop for PHP: Unimplemented functions and features

May 10th, 2011

Because of various incompatibilities and installation difficulties HipHop for PHP is not the right solution for everyone deploying PHP.

In this article I present you the documentation about unimplemented functions in HipHop for PHP compiler. This is an enhanced copy of the github’s documentation which has been deleted from project’s website three days ago by unknown reason.

The article has been enhanced with my own notes to make it up-to-date and more friendly for the end-users. Read the rest of this entry »

How to speed up the compilation of PHP code in HipHop for PHP – part I: ccache

May 10th, 2011

Compilation of any program written in PHP, depending on its size, can take anywhere from few to tens of minutes.

The long compile time is nothing unusual for C, C++ and Java developers. Unfortunately the same can not be said for PHP programmers who are accustomed to the fact that all changes in the source code are seen online in their browsers.

In this article I’ll present you one of the solutions that significantly reduces the compile time of PHP code. Read the rest of this entry »