DZone recently caught up with Marco Tabini, author of the 'Getting Started with Integrating PHP and Flex' Refcard. An accomplished author on the subject of PHP and the business of web development, Marco is co-founder of php|architect, and also a frequent speaker at PHP and OSS conferences throughout the world.
Hi Marco, can you please tell us a little bit about yourself and how you got involved with PHP development?
I have been working with PHP for around ten years now; at first, I was primarily interested in it as an alternative to ASP for my consulting practice, but eventually embraced the knowledge aspect of it, specializing in creating information products that relate to its use. Today, my consulting firm Blue Parabola produces what is probably the largest PHP publication in the world, php|architect.
In what kinds of scenarios would I need to consider integrating PHP and Flex? What are some typical use cases for this?
There are probably a number of different scenarios, but the two most likely ones are the integration of publicly-facing, web-based applications and customized AIR-based systems for internal use within a specific organization. In both cases, Flex provides excellent production value because it uses the same underlying engine as Adobe Flash wrapped in a powerful and very accessible framework.
What are some key things developers should consider when embarking on a PHP and Flex project?
First and foremost, it is unlikely that Flex will be the only interface to your backend. Therefore, it pays to build multi-tier applications whose backend and front end components are well-separated to minimize code repetition and maximize extensibility.
In addition, you should consider making your applications run on recent versions of PHP. Although Flex can interface with a wide range of PHP code, newer versions of the language include powerful data manipulation functionality that makes interfacing with Flex much easier.
What kind of support does Flash Builder 4 provide for PHP development?
FB4 comes with a set of data connectors designed to work specifically with PHP. If you set up your project properly, interfacing your Flex projects with PHP can be as simple as answering a few questions in a wizard.
Do I need to use the Zend Framework to connect my PHP application with Flex? What options do I have for connecting the two?
Zend Framework is only one of two choices—it certainly makes the most sense if you are already using ZF in your project. If you aren't, however, you can also use AMFPHP, which is equally free and open source and doesn't come with the add heaviness of the framework.
Are there any special considerations that need to be made when exchanging data between PHP and Flex?
One needs to mindful of some of the differences in data handling between the two new languages. Flex, in particular, supporters slightly higher numerical resolution of integer values, and all strings are encoded using UTF-8, which may require special handling in PHP. Most of the time, however, the exchange of data between the two is pretty much transparent.
When working with Flash Builder 4, what other data connectivity options do I have outside of AMF?
Plenty! Virtually every popular web service protocol is supported by Flex—including SOAP, JSON and pretty much any custom protocol you can come up with.
If you'd like to learn more about PHP and Flex Integration, be sure to download Marco Tabini's Refcard, 'Getting Started with Integrating PHP and Flex'.