CakeSWXPHP

By Wouter Verweirder (wouter)
SWX is the native data format for Flash. It uses SWF files to store and exchange data. It is also an implementation of an RPC gateway (currently in PHP), tools (a data analyzer/debugger and a service explorer), various APIs (Flickr, Twitter, etc.), and an ActionScript library that make creating data driven Flash and Flash Lite applications a piece of cake.
I based this code on the cakeamfphp project. The SWX project by Aral Balkan also contains amfphp 1.9. Looking at the code from cakeamfphp, I was able to get SWX running and call the cake controllers as remoting services.

Download the latest version at: http://blog.aboutme.be/cakeswxphp
Just copy/past in your cake directory! Gateway locations are:

swx.php (SWX)
amf.php (AMFPHP)
json.php (JSON)

You can test your methods, using the SWX service explorer. Point your browser to the "explorer/" directory, and you will see your cake controllers + methods as remoting services!

Currently it uses an adjusted version of SWX, based on SWX 1.0. I will try to update it to future versions of SWX when I get the time...

More info about SWX at:

http://www.swxformat.org/ http://www.aralbalkan.com/ (Aral Balkan, SWX author)

Enjoy!

 

Comments 492

CakePHP Team Comments Author Comments
 

Comment

1 bugfix

There was a bug in the php4Exception & php5Exception files, which is now fixed. You can find the latest version at http://blog.aboutme.be/cakeswxphp
Posted Aug 10, 2007 by Wouter Verweirder
 

Question

2 I dont know dude

I don't know...I'm getting all sorts of errors with the RPC calls and what not when going to the service browser/explorer.

I would really . REALLY . love some simple "drag these files into a folder and it works" type solution over the time it takes to setup the amfphp, but I'm still on the fence about all this.
Posted Sep 11, 2007 by Tom Maiaroto
 

Comment

3 Check your AMF path

I don't know...I'm getting all sorts of errors with the RPC calls and what not when going to the service browser/explorer.

I would really . REALLY . love some simple "drag these files into a folder and it works" type solution over the time it takes to setup the amfphp, but I'm still on the fence about all this.

Tom,
Make sure you are calling your path to amf correctly. I had to manually change it to http://mydomain.com/app/webroot/cake_amf_gateway.php
Posted Sep 14, 2007 by Daniel Schutzsmith
 

Comment

4 Timeout problems..

I ran through your tutorial for setting up a Flash Blog http://blog.aboutme.be/2007/09/30/flash-remoting-with-swx-and-cakephp/#comment-3217 and I got everything set up correct or so I thought. When I call the methods from my swf I get timeouts, when I call them from the Service Explorer I get timeouts...I went through the tutorial step by step (twice to be sure).

Any idea why this would be happening?

I have a sample of my problem here http://www.pbjs.com/dev/bizKids/testSWX.html
Posted Oct 11, 2007 by Ryan Davidson
 

Comment

5 AMF gateway works but SWX gateway doesnt

I can't seem to get the SWX gateway to work. I've got the AMF gateway working but the SWX gateway fails. All I did was drop the CakeSWXPHP files into a new cake (1.2.x.x) app.
Posted Nov 5, 2007 by Brian Lewis
 

Comment

6 cake 1.2 not supported yet

I can't seem to get the SWX gateway to work. I've got the AMF gateway working but the SWX gateway fails. All I did was drop the CakeSWXPHP files into a new cake (1.2.x.x) app.
Brian, currently 1.2.X.X is not supported yet. I'm working on this, expect an update in the near future!
Posted Nov 17, 2007 by Wouter Verweirder
 

Comment

7 been a while and still no joy

Still can't it to work. I specified all sorts of paths.
localhost I thought was an issue, I used an IP... no luck.
/app/webroot/ still no good.

I don't know what to say. I'm super excited about SWX but this isn't working. I'm using cake version 1.1. something...maybe I have the wrong version?

Getting some strange error about the call failing:

faultCode:Client.Error.MessageSend faultString:'Send failed' faultDetail:'Channel.Connect.Failed error NetConnection.Call.BadVersion: : url: 'http://dev.local/triv-swx/app/webroot/amfphp.php'

Any clues? AMFPHP with CakePHP was easier to setup than this and from reading the SWX site, that shouldn't be the case. Also I want to use SWX and not the AMF...I already have AMFPHP with Cake working, so even using this amfphp gateway is silly to begin with.
Posted Nov 19, 2007 by Tom Maiaroto
 

Comment

8 Other gateway locations

Still can't it to work. I specified all sorts of paths.
localhost I thought was an issue, I used an IP... no luck.
/app/webroot/ still no good.

I don't know what to say. I'm super excited about SWX but this isn't working. I'm using cake version 1.1. something...maybe I have the wrong version?

Getting some strange error about the call failing:

faultCode:Client.Error.MessageSend faultString:'Send failed' faultDetail:'Channel.Connect.Failed error NetConnection.Call.BadVersion: : url: 'http://dev.local/triv-swx/app/webroot/amfphp.php'

Any clues? AMFPHP with CakePHP was easier to setup than this and from reading the SWX site, that shouldn't be the case. Also I want to use SWX and not the AMF...I already have AMFPHP with Cake working, so even using this amfphp gateway is silly to begin with.

Hello Tom,

The path the the amf gateway would be:

'http://dev.local/triv-swx/app/webroot/cake_amf_gateway.php' 'http://dev.local/triv-swx/app/webroot/amf.php'

I'm planning to change the path's to the default SWX paths in the next commit, so amf would be amf.php, swx would be swx.php (instead of cake_amf_gateway.php or cake_swx_gateway.php) Been there, done that :-)

Good luck!
Posted Nov 26, 2007 by Wouter Verweirder
 

Comment

9 must be doing something wrong still

yea...still have that bad call error... looking forward to a future version, maybe i'll have more luck then.

maybe there's a server setting i have locally that's not jiving. who knows.
Posted Nov 27, 2007 by Tom Maiaroto
 

Comment

10 php log

yea...still have that bad call error... looking forward to a future version, maybe i'll have more luck then.

maybe there's a server setting i have locally that's not jiving. who knows.

Tom, maybe the answer is in the php error log? The location of the error might be in there...
Posted Nov 28, 2007 by Wouter Verweirder
 

Comment

11 replace loadController with import for cake 1.2

Hey guys,

We ran into the same problem when we moved our cake core up to v1.2. If you turn on debugging and view your gateway pages in your browser, you should see a message about how the loadController() method is deprecated. We just changed:

loadController(null) to App::import('Controller', 'App'); in
cake_amf_gateway.php, cake_json_gateway.php, and cake_swx_gateway.php to get our AppController class importing properly.. that fixed it with cake v1.2 for us.

best,
jon
Posted Dec 14, 2007 by Jonathan Greene
 

Comment

12 updated version

I updated the cakeswxphp packages. Changes:

- gateway locations are now amf.php, swx.php and json.php
- added a branch for cake 1.2 (thanks for the input Jonathan)

Again, you can download it at http://blog.aboutme.be/cakeswxphp/
Posted Dec 18, 2007 by Wouter Verweirder
 

Question

13 Date Datatype with AMF

Trying to work my way through the code I'm really desperate to find out how to return the Date datatype through AMF to flex with cakeswxphp.
AMFPHP itself seems to support it but how do I tell that to cakeswxphp? Any idea?
Posted Apr 30, 2008 by Thomas Seifert
 

Question

14 How to update swx versions

Thanks for sharing this!!! It really looks great!! I am going to use it in a new flash project.
One quick question: Is updating versions of swx just a matter of downloading swxphp from Aral's website and putting it in /vendors/swx/php???
Do you want to share guidelines for updating it to the newest version of swx??

Thanks!
Posted May 3, 2008 by Rafael Vega
 

Bug

15 vendor deprecated warning bug

I tried this with the latest nightly of cakephp 1.2 (5/3/2008) and every time that your code calls the function vendor, cake shows a warning (they deprecated the vendor function), I told vendor to shush with the @ thingy and it is now working like a charm!!!
That is: I changed every ocurrence of "vendor(..." with "@vendor(..."

What is the swx version included in your code?? the comments say its 1.03 beta but it says 1.0 on the explorer.

Cheers and thanks again for great work!
Posted May 3, 2008 by Rafael Vega
 

Comment

16 cakephp 1.2 updates

I updated the branch for 1.2, removing some deprecated code which caused errors in the latest version of cakephp 1.2...

Download the latest version at http://blog.aboutme.be/cakeswxphp/
Posted Jul 13, 2008 by Wouter Verweirder
 

Comment

17 Sending emails

For some reason using the email component doesn't work when using remoting? The same thing happens when i use AMFPHP. It doesn't receive any of the variables that I $this->set in the controller?
Posted Jul 25, 2008 by Craig Morris
 

Comment

18 Sending emails

Craig,

This is an issue with the current cakephp RC, which has been resolved in the svn version. Download the latest cakephp 1.2 from SVN, and it should work ok :)
Posted Aug 11, 2008 by Wouter Verweirder
 

Bug

19 Can't get the new version working

First of all, thank you for all you hard work on this. Great contribution.

I am installing the new version that uses SWX 2.0. I have put all the files in their appropriate places. I am able to load up the ServicesBrowser at /amf.php and see my controllers and actions.

Problem is when I try and run a simple index action I get the following error back:

faultString = "array_merge() [http://php.net/function.array-merge]: Argument #2 is not an array"

message = "faultCode:AMFPHP_RUNTIME_ERROR faultString:'array_merge() [http://php.net/function.array-merge]: Argument #2 is not an array' faultDetail:'/opt/local/apache2/htdocs/sales_integration/cake_1.2/cake/libs/controller/controller.php on line 950'"

Any idea what is going on?
Posted Jan 4, 2009 by Adam Duro
 

Comment

20 works here

Adam,

It works fine here... Might be a problem in your php script?
Posted Jan 4, 2009 by Wouter Verweirder
 

Comment

21 Error

When using SWX Explorer 1.0, I get the following error when calling any function from my controllers:

TypeError: Error #1009: Kan geen eigenschap of methode benaderen via een verwijzing naar een object dat null is.
at RawAmfService/readData()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()

The functions show up just fine, they are all there and what not. I installed the calculator.php test to check, and it gives this error as well. What is causing it?
Posted Jan 9, 2009 by Lawrence Lee
 

Comment

22 RE: Sending Emails

For some reason using the email component doesn't work when using remoting? The same thing happens when i use AMFPHP. It doesn't receive any of the variables that I $this->set in the controller?
Add this to your controller:

function beforeFilter() {
$this->Email->startup($this);
}
Posted Mar 19, 2009 by Devin Foley
 

Comment

23 Strings that Start with Numbers

It seems that if you send a string value that begins with a number, such as "123abc" to a controller method, by the time it reaches the method, it's value has been shortened to "123". I assume that somewhere along the line, 123abc is being interpreted as a number instead of a string, and the trailing characters are being cut off.

Anybody seen this?
Posted Mar 19, 2009 by Devin Foley
 

Comment

24 Session authentication hell

It seems that if you send a string value that begins with a number, such as "123abc" to a controller method, by the time it reaches the method, it's value has been shortened to "123". I assume that somewhere along the line, 123abc is being interpreted as a number instead of a string, and the trailing characters are being cut off.

Anybody seen this?

Same here. When passing across a session variable which often starts with a number, only the number gets passed along, which makes authenticating a session I nightmare - unless there's an obvious fix.
Think this is just occurs with the explorer. Running everything from within my own ActionScript seems to pass variables correctly. Have to admit this does cause problems trying to test results though.
Posted Apr 2, 2009 by Toby