Apr 02, 2009

CpAmf flex example

by: Daniel Verner
CpAmf flex example

Introduction

The example is based on test application for cakeAMF plugin:
https://trac.cakefoundation.org/amf/wiki/tutorial/amf
Thanks to developer(s) of cakeAMF plugin. Any comments and suggestions are welcome.

The application uses the MATE framework, for event handling and remoting:
http://mate.asfusion.com/

UPDATE: A non MATE version of this example is also available, so if you prefer the "pure" flex 3 technology, check out the article.

The MATE framework is a very userful tool to build complex application with flex. For this example it wasn't necessary to use the MATE, but I wanted to show how to use the cpamf plugin with that powerful framework. The plugin can be used without MATE; using RemoteObject, or with simple NetConection.

The example is a very simple "user management" application. You can list all users, get a user by id, and insert new user to the database.

Download

Download the example here.

See also

CpAmf php example.
CpAmf non MATE flex example.

Share this post:

19 comments

bomb

bomb

Thank you, It good job wow

Apr 20, 2009 (03:58:10) - #1
alan

alan

Daniel,

Sorry to trouble you. I'm new at Cake.. I can't get the

but on the http://localhost/cpamf_test/

I can see the "Release note" default page. I've setup the database and data but still no luck with
localhost/cpamf_test/cpamf/gateway.

It gives 404 error. Any clue? Thanks in advance.

May 08, 2009 (03:44:08) - #2
alan

alan

Argghhh.. the last comment shall be in the CAMF test page..

May 08, 2009 (03:45:27) - #3
Daniel Verner

Daniel Verner

@alan
If you see the default page, then the cakephp is set up correctly.

Mod rewrite should be enabled, and set AllowOverride All in httpd.conf

May 08, 2009 (08:45:10) - #4
alan

alan

hi... I got cake and cpamf working... but the flex program cannot get data from it... it just gives me error message.. I tested the gateway on browser, it works fine... any idea? Do I need to change the salt?

May 11, 2009 (08:17:49) - #5
Daniel Verner

Daniel Verner

What kind of error messages you get? If it is a security sandbox violation, try to change the gateway url in services-config.xml (from 127.0.0.1 to localhost), and than recompile the flex application.

May 11, 2009 (10:58:23) - #6
alan

alan

It's not sandbox violation... The error is from:

Alert.show( faultString, "Error!" );

what shall I do to reslove it?

May 12, 2009 (03:26:55) - #7
Ramiro Araujo

Ramiro Araujo

Hi Daniel
Great work!! Im having a little problem making the browser work. I can enter the browser, and the gateway is correct, but then the browser ask for getServices method, which is doesn't exist, and I can go past that. I can see the remoting call from ServiceCapture,

I see the method is implemented in the discovery_service_controller, but how is that controller tied up with the browser? The getServices points to the service 'amfphp'...

thanks!

May 22, 2009 (00:39:45) - #8
Daniel Verner

Daniel Verner

The discovery service controloler is a special controller, the service call is checked in the CakeActions.php, and if it is a Amfphp.DiscoveryService, then the discovery service controller is called. Could you be more specific about your problem, so we can resolve it.

What you get when you enter the gateway url to the browser? (localhost/cpamf/gateway)

May 22, 2009 (08:52:49) - #9
François Greze

François Greze

hi ,
Thanks you for your very useful "cakephp" adaptation of the amfphp library...

I have all ready put a cool and nice backend on tracks using your plugin ... :) thx a lot then !!

One quesstion : what do you think of the zend_amf library ?
happy coding ...

Jul 09, 2009 (18:21:27) - #10
Daniel Verner

Daniel Verner

Before starting my plugin's development, I've checked out zend_amf too. It looks promising, and it is also supported by Adobe and the Zend community.
I had 2 reasons to choose AMFPHP over zend_amf:
1. AMFPHP can take the advantage of the AMF extension (serializing and deserializing AMF data using native C implementation), as far as I know zend_amf can't use the AMF extension yet.
2. Our team used AMFPHP before, and we had good experiences with it.

Would you like to show us your project which is based on this plugin? We'd like to check it out. If you don't want to show your link public to the public, you may e-mail us. Thanks!

Jul 09, 2009 (20:14:09) - #11
François Greze

François Greze

Hi Daniel,

Sure as soon as it's online, I'll send you a link ...

There is nothing special by about this project, but I'll give you a buzz when my code is cleaner :) and all the functionalities I Have in mind are working .

Keep in touch then !

FG

Jul 10, 2009 (23:07:10) - #12
Gustavo

Gustavo

¡ALELUYA!
I was having the problem related to the service browser. The cpamf_test sb works fine but the sb inside my application didn't (I tried out v0.10 and v0.12). I copied the contents of the plugins directory of the cpamf_test to my application and now the sb is ¡working!.
I will do some tests and call for help if neccesary.
Kind regards
Gustavo

Sep 28, 2009 (21:49:37) - #13
Ricardo

Ricardo

Hello, where I put my flex project files (withou MATE) on cakephp folders?

Nov 21, 2009 (12:49:42) - #14
Daniel Verner

Daniel Verner

@Ricardo

You can put the flex project anywhere you want. You should put the bin-debug folder somewhere in your webroot, to prevent security sandbox violation.

Nov 23, 2009 (10:38:36) - #15
Ricardo

Ricardo

Hello again Daniel, thank you to answer my question!
Sorry about that but, could you make an more simple and step-by-step tutorial to use your plugin? I'm really want to use that but I don't understand where to put my files and how CakePHP map an view to Flex project.

Nov 23, 2009 (12:57:08) - #16
Samuel Mburu

Samuel Mburu

Daniel, thank you for the great tutorial. I just had a question for you as well as anyone else(hopefully I'm not the only one with this issue).

So it runs fine locally, but when I push it to my webserver and try to hit the 'Get All Users' button, I get a 500 error when the flex tries to look for crossdomain.xml. What's really wierd is using firebug I was able to see that it looks for http://localhost/crossdomain.xml, which is not right at all.

Did I forget to configure something?

Here is the site url so you can see this for yourself:
http://cake.blue-eel.com/cake1.2.x.x/fl ... _mate.html

Thanks
Samuel M.

Jan 14, 2010 (14:58:26) - #17
Daniel Verner

Daniel Verner

Check your services-config.xml. Maybe your gateway is not set up correctly. If you make changes in the services-config.xml, you may need to clean and rebuild the project.

Jan 14, 2010 (15:29:22) - #18
Samuel Mburu

Samuel Mburu

Wow, thank you Daniel V. I've been wrestling this for a while. I rebuilt the project and everything works, now I can move on to the next step.

See my thought was that the services-config.xml was used during runtime, but now I know that build time is where the magic happes.

Thanks again,
Samuel M.

Jan 14, 2010 (16:05:59) - #19

Your reply

You can't use HTML, but URLs will be automatically linkyfied and Your e-mail address will never be published. We reserve the right to moderate Your comments. Gravatar service is used for avatars. Upload yours at www.gravatar.com.

All fields marked with an asterisk (*) are required!

Remaining characters

security image