views:

19

answers:

2

I have an OOP PHP site structured with a MVC pattern. A page on the site has an embedded SWF that needs to pull information from a database. In the past, I would have just had a procedural php file for the swf to load the data from the database from. However, that method doesn't seem like it would fit with a more objected oriented site.

What would be the "proper" way for the swf to load external data? Should I create a class and a MVC pattern in the normal structure of the site that can pull the data (e.g. mysite.com/flash/data) and just pass this path to the swf as a FlashVar?

A: 

You could write one or more classes that provide the data your flash program needs and then expose the classes' methods through SOAP with SoapServer. See here how to work with XML and namespaces.

Artefacto
SOAP is a huge pain in the ass, and PHP's SOAP implementation moreso than most. It seems like massive overkill for what is essentially intended to be an internal API.
Kalium
A: 

I suggest that first you create a RESTful API based on the MVC code. Provided your framework is sane, this should be easy. Second, I suggest you use either AMF or JSON to pass data around. That way your SWF can make web calls in the background and get all the data it needs from your application.

Kalium