Jun 26, 2009

CpAmf v0.11 released

by: Daniel Verner

IMPORTANT: Cpamf is updated to v0.12. This is a bugfix release, so it is highly recommended to update to this version. For more details check the release_notes.txt. To get the new version check the download section below.

Introduction

CpAmf v0.11 is released. There are some minor enhancements, and bug fixes in this release:

  1. Service browser displays methods beginnig with specified prefix
  2. Debug mode always 0
  3. CpAmf works with CakePHP Auth component

Using the service browser

AMFPHP comes with a handy utility called service browser, which is useful for testing the services (or in this case controllers). Although you can test your controllers with CakePHP itself, but if you want to test them using flash remoting you can use the service browser. The browser is accessible at the following url:

yourdomain.com/cpamf/browser

NOTE: The service browser is accessible only when the 'Cpamf.serviceBrowserEnabled' is set to 1 in the cpamf_app_controller.

CakePHP controllers have many inherited methods from the AppController, and usually we don't need to see nor access them through the service browser. If the method prefix is set in the vendors/amfphp/globals.php (define( "METHOD_PREFIX", "prefix" );), then the service browser will only display methods beginning with the specified prefix.

Debug mode disabled

The CakePHP debug mode is always set to 0 in the CpAmf plugin's AppController. This is a necessary step to prevent the CakePHP's SQL Log to appear in the output. Any unwanted strings in the output would result in a "Channel Disconnected" error on the Flex client side.

Authentication

In the previous version of the CpAmf plugin there was a problem using the plugin with the enabled Auth component. In this release this bug is fixed. When the Auth component is enabled, the cpamf plugin allows three actions in cpamf_controller: index, gateway, and browser. These actions are allowed to all users. All other controller actions (used through the CpAmf plugin) are controlled by the main application.

You can find more information about the usage of the Auth component here:
http://mark-story.com/posts/view/auth-and-acl-an-end-to-end-tutorial-pt-1

More information

For more information  about this plugin see the included readme.txt, or check out the previous CpAmf article:
http://carrotplant.com/en/blog/flex-remoting-with-cakephp-cpamf-plugin

Download

CpAmf plugin v0.11 (zip)

CpAmf plugin v0.12 (zip)

Share this post:

22 comments

Daniel Alexandrov

Daniel Alexandrov

The plugin looks realy promising but it seems that the archive is broken. Atleast I cant open it.

Jul 02, 2009 (12:39:34) - #1
François Greze

François Greze

Hi,
just starting with you pluging , but the link to the v0.11 donesn't work ... the archive is empty .

Thx for sharing this anyway
happy coding form paris.
FG

Jul 05, 2009 (15:11:08) - #2
Daniel Verner

Daniel Verner

I uploaded the plugin in zip format.

Jul 06, 2009 (09:54:14) - #3
François Greze

François Greze

Works now [^.-]

THX.

FG

Jul 10, 2009 (22:49:46) - #4
Chris

Chris

Hi

The archive of non Mate example seems to be broken. Could you check it?

Jul 17, 2009 (14:01:45) - #5
Chris

Chris

Naah.

Upper comment should be in cpamf-non-mate-flex-example article. Probably you have some sessions here which checks the last page, and I was changing pages in another tab.

Jul 17, 2009 (14:05:11) - #6
Peter Jankovich

Peter Jankovich

@Chris: Yes, we are aware of this session bug, but we had no time to fix it. Anyway the new version of this site is in the works... It will be nicer and will contain (hopefully) less bugs :)

We'll check that link to that archive.

Jul 17, 2009 (20:18:34) - #7
Craig

Craig

Hey mate,

Great work it's good to see this as a plugin! Just a small bug that the browser can't find the javascript file when Router::parseExtensions is turned on. This would be fixed if you put the javascript files in the appropriate folders inside the vendors folder, ie. app/plugins/cpamf/vendors/js/amfphp/browser/AC_OETags.js

Cheers,
Craig

Aug 20, 2009 (06:53:35) - #8
Peter Jankovich

Peter Jankovich

@Craig:
Thanks for finding our project useful and also thanks for your feedback! We'll fix that bug in the next release.

Aug 27, 2009 (23:59:54) - #9
Momo the Monster

Momo the Monster

I'm using 0.12, and yet I still seem to be running into Auth problems. I get this error on any CakePHP app where I've got Auth running:

(mx.rpc::Fault)#0
errorID = 0
faultCode = "AMFPHP_RUNTIME_ERROR"
faultDetail = "/nfs/c03/h05/mnt/49962/domains/f2c.mmmlabs.com/app/plugins/cpamf/controllers/components/amf_auth.php on line 34"
faultString = "You are not authorized to access that location."
message = "faultCode:AMFPHP_RUNTIME_ERROR faultString:'You are not authorized to access that location.' faultDetail:'/nfs/c03/h05/mnt/49962/domains/f2c.mmmlabs.com/app/plugins/cpamf/controllers/components/amf_auth.php on line 34'"
name = "Error"
rootCause = (null)

Any ideas?

Sep 16, 2009 (07:55:11) - #10
Adam Duro

Adam Duro

Great plugin. I just switched my app over to it from the CakeAMF plugin. I find it's a much tighter implementation of AMFPHP, in fact, probably the tightest implementtion I've seen for Cake.

Good work. It would be great if you guys could work up an implementation that uses Zend AMF and is as well integrated as this. Since that is the direction that AMFPHP is going in. I have seen a few attempts and tried them out, but so far not a huge fan (Zamf, Flexible Cake)

Sep 17, 2009 (02:54:53) - #11
Daniel Verner

Daniel Verner

@Momo the Monster

The problem you mentioned is ACL related, but we need more information about your controllers and acl. You may contact us by email.

Sep 17, 2009 (08:49:28) - #12
Daniel Verner

Daniel Verner

@Adam Duro

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.

In the future, when Zend AMF will support amf extension, maybe we will create an another CakePHP plugin based on Zend AMF.

Sep 17, 2009 (08:58:53) - #13
toby

toby

hi there,
I have got the browser working AOK on my local WAMP set up, but when I upload the exact same files to my server i get the bad gateway error? I can go the gateway address fine and get the success page, but the browser just flat out fails to accept the gateway address...
Any advice please?
t.

Nov 02, 2009 (10:39:42) - #14
kbalcerek

kbalcerek

How to get access to controller in plugin. In the example attached UsersController is in app/controllers/ folder. I need to call method on controller that is in plugin, so it would be app/plugins/plugin_name/users_controller.php
I have tried PluginName.UsersController in source attribute of RemoteObject, but it doesn't work. Anybody have any idea how to resolve it?

Dec 03, 2009 (11:39:51) - #15
kbalcerek

kbalcerek

Hi All,
Nobody answered and I didn't found any solution in google, so after a few evenings I did my own... I didn't test it very well, but for now it is working fine for me.
My base version was v0.12
After changes adviced by Roel found under
http://carrotplant.com/en/blog/cpamf-php-example
I changed 2 more files, you can download them here: http://uploading.com/files/b4652ce9/cpamf.zip/

It is important to set $pluginPaths variable in bootstrap.php file.

Hope it will help somebody... :)

Dec 15, 2009 (02:43:03) - #16
Ramiro Araujo

Ramiro Araujo

Hi Daniel
I've been using your plugin and it rocks!
A few things I do to tune it up a little:
1. I add a 3rd parameter to _listServices, which is a regexp to filter controllers. All my remoting controllers are prefixed with "remoting_". That's just my choice of course, but right now you have a method filtering and not a controller filtering.
2. I'm not very experienced in class reflection, but the ReflectionClass of php5 seems to get all the inherited methods, and you don't usually need those in the service explorer. I basically use the php4 option :)

That's it :)
Thanks a lot for the plugin!
Ramiro

Dec 26, 2009 (18:28:08) - #17
Julius

Julius

How do I setup the auth component to work with flex? I get the "You are not authorized to access.." error even if I am calling the login method. I followed the tutorial on auth, but I can't get past this one.

I manually allowed the login method and the error was gone. But the auth user still wasn't set

Jan 05, 2010 (09:32:13) - #18
Tyson

Tyson

I just upgraded from version v0.10. I am using Air to access the gateway. In the previous version I was able to send a token to authenticate the user and then carry out the requested method.In v0.12 i send the token, it authenticates the user succesfully, but I still get "You are not authorized to access that location."

I'm not sure why it does this in gateway. If i pass the token to the browser, it authenticates correctly and continues to successfully get the requested method.

Any help?

here is my BeforeFilter in /controllers/cpamf_controller.php
function beforeFilter()
{
if( isset( $this->Auth ) )
{
$this->Auth->allow( array( 'index', 'gateway', 'browser' ));
}
if( !$this->Auth->user() && isset($this->params['url']['token']) )
{
$this->User->authenticate($this->params['url']['token']);
$this->Auth->login($this->User->data);
}
parent::beforeFilter();
}

Jan 15, 2010 (17:42:52) - #19
tyson

tyson

If fixed the problem. For those that have the same problem keeping logged in from Air: You need to set the Auth in the initCakeController in CakeActions.php when creating the requested controller.

Sorry for being so vague.

Jan 15, 2010 (22:28:52) - #20
Samuel Mburu

Samuel Mburu

All, so I built my backend, models and controllers with bake(very cool) and built the matching classes in flex.... the only thing now is that when I pass my objects from the backend to flex all of my ArrayCollections contain [object object].

even after I bind it to a drop down.

Any body else have the same error.

Thanks,
Samuel M.

Jan 19, 2010 (21:20:02) - #21
siddharth mandal

siddharth mandal

Hi Frends,
I used the cpamf v0.12 plugin.
after installation i got the following msg.

amfphp and this gateway are installed correctly. You may now connect to this gateway from Flash.

But, whenever i am using the "Load the service browser" link, i am getting the following error.

(mx.rpc::Fault)#0
errorID = 0
faultCode = "Client.Error.MessageSend"
faultDetail = "Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Status 404"
faultString = "Send failed"
message = "faultCode:Client.Error.MessageSend faultString:'Send failed' faultDetail:'Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Status 404'"
name = "Error"
rootCause = (Object)#1
code = "NetConnection.Call.Failed"
description = "HTTP: Status 404"
details = "http://localhost/cpamf_test/cpamf/gateway.php"
level = "error"

plz. help me out.

Feb 10, 2010 (10:59:43) - #22

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