Jump to content
Larry Ullman's Book Forums

Data Services Using Amf!


Matt
 Share

Recommended Posts

Hi Larry,

 

Sorry I haven't been around here in a while. I've been working on other stuff and busy with work!

 

I just started reading your book again and went through chapters 7 and 8. I wanted to say that the whole data services with Flex thing can be a bit overwhelming at first, how ever I think you did a fantastic job of teaching it without skipping over any important information (which other books I've seen have done). It's all making perfect sense so thank you for that!

 

I'm on chapter 9 now and getting into RPCs with AMF. I had a couple of questions:

 

1) It appears that AMFPHP 2.0 is out now and a few things have changed. The gateway.php file is now gone and the documentation is sparse at best. I had to go into a forum to figure out what they could have taken 5 minutes to explain in the "Installation Guide". Anyway, it's now just called index.php in the Amfphp folder. You can also go directly to this page to see the "Services Browser". The documentation also says that on a production server, you should copy this file and your services to folders outside of Amfphp. I understand what they mean, but I don't want to break anything. I just wanted to get your take on this. Is there anything I should be aware of?

 

2) I am testing on a remote server, so I don't have a WAMP environment set up. Is it possible to use the Flash Builder Data Service wizards to generate code if you are working from a remote server? Also, I don't want to install the Zend Framework because I don't want extra convoluted framework code taking up space on my server when I only need the AMF services. I want to use AMFPHP if possible. Is there any benefit to letting Flash Builder create my service code, or is the code you wrote good enough?

 

3) I downloaded the example code for the book and noticed that if Flash Builder writes the code, it doesn't seem to use the RemoteObject component, but uses a CallResponder instead. What is that? Why wouldn't it use a RemoteObject? Is their any benefit to using one or the other. This is one reason why I don't like to use wizards for stuff like this. They use/do things that one would not think is the way to solve the problem and they hide certain things in the background!

 

Sorry for the long comment! Thanks in advance Larry!

 

Matt

Link to comment
Share on other sites

Sorry I haven't been around here in a while. I've been working on other stuff and busy with work!

 

I just started reading your book again and went through chapters 7 and 8. I wanted to say that the whole data services with Flex thing can be a bit overwhelming at first, how ever I think you did a fantastic job of teaching it without skipping over any important information (which other books I've seen have done). It's all making perfect sense so thank you for that!

 

 

 

Hey Matt,

 

No need to apologize for doing other things. I hope you're doing well. Sorry for the delayed reply; busy week. Thanks, too, for the nice words on the book. Yes, Flex and Flex+PHP can be hard to grasp.

 

1) It appears that AMFPHP 2.0 is out now and a few things have changed. The gateway.php file is now gone and the documentation is sparse at best. I had to go into a forum to figure out what they could have taken 5 minutes to explain in the "Installation Guide". Anyway, it's now just called index.php in the Amfphp folder. You can also go directly to this page to see the "Services Browser". The documentation also says that on a production server, you should copy this file and your services to folders outside of Amfphp. I understand what they mean, but I don't want to break anything. I just wanted to get your take on this. Is there anything I should be aware of?

 

I haven't looked at AMFPHP 2 yet myself. You don't want the services browser to be publicly available, but if that's also the gateway, then I don't know what the options are. There must be something else going on here.

 

2) I am testing on a remote server, so I don't have a WAMP environment set up. Is it possible to use the Flash Builder Data Service wizards to generate code if you are working from a remote server? Also, I don't want to install the Zend Framework because I don't want extra convoluted framework code taking up space on my server when I only need the AMF services. I want to use AMFPHP if possible. Is there any benefit to letting Flash Builder create my service code, or is the code you wrote good enough?

 

You can definitely use the code I provided. What I normally do is have FB build the code and then I just edit it. For example, you can use ZF on your local server, develop, test, and debug everything, and then just change the URL in the ActionsScript code to point to the file, live server, which can use AMF. It's a bit of a pain in the ass because FB will try to change the URL back every so often, so you have to watch for that, but it's an happy compromise to me.

 

3) I downloaded the example code for the book and noticed that if Flash Builder writes the code, it doesn't seem to use the RemoteObject component, but uses a CallResponder instead. What is that? Why wouldn't it use a RemoteObject? Is their any benefit to using one or the other. This is one reason why I don't like to use wizards for stuff like this. They use/do things that one would not think is the way to solve the problem and they hide certain things in the background!

 

Off the top of my head, I don't know, except to suggest what you already think: wizards often take a generic, easy way out.

Link to comment
Share on other sites

Larry,

 

Thank you for your response!

 

I haven't looked at AMFPHP 2 yet myself. You don't want the services browser to be publicly available, but if that's also the gateway, then I don't know what the options are. There must be something else going on here.

 

I set up the database for the chapter 9 products app on my hosted server and got AMFPHP 2 installed. When I tested the app, everything worked fine except that I could only READ and DELETE records. This was strange, and I thought I made a coding mistake, however, when I went into the browser and tested the CREATE and UPDATE functions they worked fine.

 

Having tried everything, I then decided to install and test with AMFPHP 1.9. I set it up in about 5 minutes, changed the url in the flex app., uploaded everything and it worked perfectly (with CREATE and UPDATE working as expected)! I don't know what to make of this! Something is definitely going on with AMFPHP 2.

 

Here is the link to the AMFPHP 2 browser on my server:

http://www.tuesdaygi...ervices/Amfphp/

(I'm trusting that this won't get abused, but posted it so others can see the browser for AMFPHP 2.)

 

It appears that they have done away with using a Flex app. to test the functions and now everything is done with HTML/PHP. Also, notice that the url is index.php.

 

The AMFPHP site is pushing everyone to upgrade from 1.9 to 2.0, however, after what I've experienced I'm not too sure what the benefits would be.

Also, it appears that there is some transition in ownership of the project and there is a new website:

http://www.silexlabs.org/amfphp/

 

I thought about making this a new thread because I feel that it is an important change to AMFPHP. New users who try to use the book's examples with AMFPHP 2 will certainly experience the same headaches I did. The only thing I can suggest is just staying with the older version.

 

If you have some time Larry, you might want to look into this. I would love to hear your thoughts and advice about this!

 

You can definitely use the code I provided. What I normally do is have FB build the code and then I just edit it. For example, you can use ZF on your local server, develop, test, and debug everything, and then just change the URL in the ActionsScript code to point to the file, live server, which can use AMF. It's a bit of a pain in the ass because FB will try to change the URL back every so often, so you have to watch for that, but it's an happy compromise to me.

 

Good idea! My use case is, in fact, very simple. I am just reading in a list of file names from a database and using it to populate a drop-down list, so nothing too complicated. I will just use your code then!

 

Thanks again,

 

Matt

Link to comment
Share on other sites

Larry,

 

I took a look at the code again this morning and I think I figured it out!

 

As I said, only the CREATE and UPDATE functions don't work with your Flex app. and AMFPHP 2. Those are the only 2 functions which are receiving data to be inserted into the database. I thought that it was possible that AMFPHP 2 has changed from passing an ActionScript object to PHP as an associative array and now appears to pass an ActionScript object to PHP as a "generic object" (like Zend does). I changed the PHP code to reflect the changes you make to the script on page 307, uploaded it, and it worked as expected!

 

I did look at the AMFPHP documentation to see if this is mentioned, but as I said above, the documentation is a bit high level and vague. They mention several new data types, but don't seem to mention anything about a "generic object".

 

Here is the documentation on AMFPHP 2 data types:

http://www.silexlabs.org/amfphp/documentation/data-types/

 

Is the "undefined" data type a "generic object"?

 

What can you make of all this Larry?

 

Matt

Link to comment
Share on other sites

 Share

×
×
  • Create New...