Meeting the people behind the most exciting homegrown OSS projects.

Open source spotlight: PHP-CPP
Keine Kommentare

This month, we speak to Emiel Bruijntjes about PHP-CPP, a new library for writing PHP extensions in C++.

WPM: Who’s behind PHP-CPP?

Bruijntjes: I am founder and CTO of Copernica Marketing Software and have been a PHP programmer since 2000. I’ve programmed using C/C++ since 1995.

Why did you decide to start it? And why did you make it open source?

While PHP is an easy to use language with a great syntax, it also has some issues. Compared with C++, it’s very slow and uses a lot of CPU. Wanting to improve the performance of the PHP based Copernica by mixing in some C++, I started studying the internals of the PHP engine.

But despite the fact that this is currently the only way to combine PHP and C++, I found out that it is far from easy to use. PHP extensions are very hard to implement and require a deep knowledge of the Zend engine and pointer manipulation. Acquiring this knowledge is also nearly impossible to do, as clear documentation is barely available.

Even if I took the time to learn how to develop PHP extension with the PHP API, my fellow developers at Copernica would have to learn to do so as well.

I decided there had to be a better way to combine PHP and C++. Creating the necessary libraries however would be too difficult for me to achieve alone. That’s why I decided to ask the open source community for help. Also because this is a project that can be of value for a lot of PHP developers, not just me.

What are PHP extensions useful for?

Well, of course there is the performance issue. By mixing PHP and native you can speed up processes. If you have a website for example, you can reduce the load time of your website. Or accelerate the performance of your software.

A lot of developers now decide to just plug in some extra servers to compensate for the extra CPU load PHP code generates. While it doesn’t have to be that way if you replace certain parts of your PHP algorithms with C++.

But going full native is not an option either. For a lot of developers it’s a language that’s too hard to master. PHP is a much more forgiving language than C++. Also, whenever you make a mistake in PHP, you can exactly see where something went wrong in the log file. Opposed to C++, where small mistakes can result in fatal crashes.

How does PHP-CPP make them easier to create?

The PHP-CPP library uses C++ features as operator overload, casting overloading and implicit constructors. This allows you to use C++ objects as if they were PHP variables. Because of this, extenstion creators will be able to create very straightforward code. All complicated constructions with memory management and pointer manipulation will stay hidden and handled by the PHP-CPP library.

On the homepage you’ll find a few examples of how easy it is to use C++ to create extension for PHP. That’ll give you a better idea of exactly how easy it is.

How can people get involved in the project, and what can they do to help out?

People can visit or go to the GitHub repo and contribute to the page there. We are of course looking for C(++) and PHP developers, as well as people that would like to help compose the documentation. A library’s success stands or falls with clear documentation that helps to use it easily.

Where do you hope to see the project in a year’s time?

In a year’s time I’d like to see that PHP-CPP is the jQuery for PHP. Just like it’s normal to not address the DOM with Javascript, I’d like to see that creating native extensions will no longer be done through the Zend engine, but through PHP-CPP.

Also, I hope that there will be a core team of a few people that develop the library themselves. Also, I expect the library to be used for other libraries like Symphone, CakePHP, FuelPHP and Lavarel. These frameworks could increase their performance significantly with PHP-CPP.

Unsere Redaktion empfiehlt:

Relevante Beiträge

Hinterlasse einen Kommentar

Hinterlasse den ersten Kommentar!

Benachrichtige mich zu:
- Gib Deinen Standort ein -
- or -