Introduction to Flex Using PHP
Let’s step back and look at what Flex is and how it compares to standard HTML development with a language like PHP. Both the traditional Web 1.0 HTML architecture and the Flex-based architecture are shown in following Figure.
Figure 1. The Flex architecture compared to the standard PHP web page architecture
On the left, you can see the standard PHP workflow you’ve come to know. The browser makes a request of the PHP web page, which talks to the database and sends back HTML to satisfy the customer’s request.
On the right is the Flex approach. The customer navigates to the page, where a Flex application (a SWF file) is loaded that contains the user interface for the form. This Flex application then uses XML to read or write data to the PHP pages on the server. Those new PHP pages talk to the database and return XML to the Flex application for display. The dashed lines on the list.html and list.swf files indicate that they were generated by Adobe Flex Builder 2.
The advantage of Flex is that the framework provides an amazing set of interface tools that make it easy to build highly interactive user interfaces. In addition, there are many advantages to having the PHP pages return XML instead of (or in addition to) HTML. Here are just a few:
- Desktop applications, such as Microsoft Office Excel, are starting to consume XML, making it easier for your customers to access their data.
- Your customers can write or modify their own applications to use your XML instead of screen scraping your HTML pages.
- If you choose a standard XML data format, such as RSS, specialized readers support the format.
- You can use XSL to query or format the data from the server however you choose.