CakeSWXPHP

By Wouter Verweirder aka "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 Fri, Aug 10th 2007, 07:55 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 Tue, Sep 11th 2007, 10:00 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 Fri, Sep 14th 2007, 23:47 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 Thu, Oct 11th 2007, 13:49 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 Mon, Nov 5th 2007, 08:56 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 Sat, Nov 17th 2007, 12:26 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 Mon, Nov 19th 2007, 13:23 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 Mon, Nov 26th 2007, 10:02 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 Tue, Nov 27th 2007, 14:51 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 Wed, Nov 28th 2007, 09:20 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 Fri, Dec 14th 2007, 11:13 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 Tue, Dec 18th 2007, 12:47 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 Wed, Apr 30th 2008, 08:35 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 Sat, May 3rd 2008, 14:42 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 Sat, May 3rd 2008, 17:35 by Rafael Vega

Login to Submit a Comment