• by Boz on Wednesday, September 26, 2007 at 12:00pm

      The PHP programming language has solidified itself as the language of choice for many top internet properties, including Facebook. PHP is easy to use and integrates well with Apache, Memcache, and MySQL. Despite its suitability for web development and scripting, PHP is generally not the best choice for standalone software or servers. C++, on the other hand, is well suited for building both online and offline services.

      Unfortunately, if the new services operates with data managed by the existing PHP code base it can be dangerous to use a separate data access pattern. If the cache keys or database schema were to change in the PHP code base then the service would be broken (and potentially corrupting data for the PHP code base) until the code was updated and the program recompiled and restarted.

      Faced with this problem we decided to embed the PHP Interpreter into C++ binaries. This isn't a novel endeavor by any means; Apache uses the PHP Server API (SAPI) to accomplish exactly that. However, when we began attempting integration of our own we found that the SAPI required quite a bit of expertise to manipulate effectively.

      In order to make embedding PHP truly simple for all of our developers we developed the PHPEmbed library which is just a more accessible and simplified API built on top of the PHP SAPI. The library is so useful, we decided to share it with the world. Check it out for yourself at http://developers.facebook.com/phpembed/



      Boz is a software engineer at Facebook and, like PHPEmbed, he is open source

Most Popular Stories

Newsroom

Newsroom

Visit the newsroom for the latest updates from Facebook.

Facebook Favorites

Blog Archive

Looking for a specific post? Visit our full archive of blog posts sorted by categories and dates.