The Developer.com article I wrote last year, 10 Experimental PHP Projects Pushing the Envelope, was originally intended to be little more than an homage to nontraditional PHP efforts that stretched beyond standard Web application development tools such as PHP-GTK and phpList. However, upon further investigation, it soon became clear that the PHP community was stretching PHP’s capabilities far beyond client-side development and newsletter administration, creating Lisp implementations, IRC bots, and interactive shells. Not only did this article turn out to be very entertaining to write, but it wound up being one of the most popular articles I wrote for Developer.com in 2010.
Entering the new year I wondered whether still other crazy and experimental PHP projects existed that I hadn’t encountered the first time around. As it turns out, plenty of others exist. In this article I highlight nine more projects guaranteed to pique your interest.
1. PHP For Android
Although the iPhone and iPad dominate today’s Zeitgeist, Android-driven competitors such as the Galaxy Tab are steadily capturing a greater share of the market, led notably by the already strong and growing Android-based smartphone and tablet market.
If you’d like to learn more about PHP for Android, check out the introductory tutorial, Build Your First PHP for Android Application by Keith Vance.
Certain database tasks involve a greater degree of complexity than can be accomplished using a standard SQL statement. To accomodate this complexity, many database solutions support stored procedures, which encapsulate the logic required to complete the task within a subroutine. The subroutine behaves much like any function found within a programming language such as PHP.
While these procedures can be written using SQL syntax (which you may not be aware includes both conditional and looping syntax), many database solutions support the ability to write stored procedures using other languages. For instance, PostgreSQL can execute stored procedures written in C, C++, Java, Ruby, Perl, and Python, among other languages. Thanks to the PL/php project, you can write stored procedures using the PHP language!
When you have PL/php installed, you’ll be able to define and execute PHP-driven stored procedures within PostgreSQL just as you can with any other supported language. This allows you to take advantage of PHP’s familiar conditional, looping, and array syntax throughout.
My original article 10 Experimental PHP Projects Pushing the Envelope mentioned the PHP-GTK project, which allows you to write desktop applications thanks to the project’s implementation of the GTK+ bindings. To date, developers have used PHP-GTK to create games, blogging software, chat clients, and even a full-blown mail client.
The PHP-Qt project offers similar capabilities to Qt developers, providing an object-oriented interface to Qt 4. Although a very interesting idea, it appears as if this project has not been actively maintained in recent years, so digging up additional details was next to impossible. If you’re using PHP-Qt, tell us about your experience in the comments!
Earlier this year, Ruby core team member Aaron Patterson released phuby, a proof-of-concept gem that makes it possible to run PHP code within Rails applications. Although Aaron has created several videos demonstrably proving phuby’s ability to run PHP code from within Rails, his tongue-in-cheek Ruby mailing list message announcing phuby’s release indicates that doing so might not be such a desirable feature within the Rails community after all.
5. The Other Phuby
Sean Huber also released a project named phuby, which bears no relation to the previous project although it shares a PHP/Ruby focus. This phuby adds several interesting Ruby features to the PHP language simply by adding the phuby project to your PHP installation’s
include_path. Although still in the early stages of development, phuby already brings Ruby mixins to PHP, splat capabilities, and send and respond_to methods, among other features. Planned features include adding alias_method and alias_method_chain.
6. Objective-PHP and Moka
Objective-PHP and Moka are two ambitious projects headed by Stephen Lerodiaconou. They add Objective-C language and Cocoa framework features to the PHP language, respectively. The project documentation states these features could make PHP attractive to Capucchino developers seeking a language that complements their existing skills.
You can watch an impressive video tutorial in which Stephen demonstrates the capabilities of these projects.
Want to use your favorite programming language to interact with an Arduino, ham radio, or video camera? Believe it or not it’s possible using the php-serial class. When installed, this class makes it dead simple to communicate with a port simply by calling the
deviceSet() function, passing the serial port name you’d like to use, and then using simple read and write methods as desired. For example:
$serial->sendMessage('Sending a message to the port!');
PHP seems to be increasingly popular within projects involving serial communication. For instance, check out this pretty amazing project involving arduinos, LCD screens, the XBee, and PHP.
As of iOS version 3.0 you can send push notifications to an iOS-powered device such as an iPhone or iPad. This feature has since become commonplace within countless applications, serving to keep the user abreast of weather alerts and news updates, or to let the user know it is his turn to make a chess move. These notifications are sent from the application developer’s server, communicating with the Apple Push Notification Service (APNS) to send the messages.
You can use Apns-PHP to send these notifications via a PHP script, meaning it would be trivial to send users notifications in conjunction with blog updates, recent Tweets, or any other event that could be monitored by PHP or retrieved from a database. The Apns-PHP documentation indicates that implementation of the APNS API was completed on December 17, 2010, offering support for custom notification images and a localized action button, among other features.
A great tutorial highlighting Apns-PHP’s use in a real-world application can be found here.
Continuing with the Apple theme, the Cocoa framework uses the property list to manage serialized data. These property lists can be managed using proprietary Apple utilities such as plutil. However, developers may wish to use other means to manage this data. As such, numerous open source projects have been created for this purpose. One such project is CFPropertyList, which allows PHP developers to create property lists which can then be sent to an iPhone application.
About the Author
Jason Gilmore is the founder of the publishing, training and consulting firm WJGilmore.com. He also is the author of several popular books, including “Easy PHP Websites with the Zend Framework”, “Easy PayPal with PHP”, and “Beginning PHP and MySQL, Fourth Edition”. Follow him on Twitter at @wjgilmore.