Using CakeAMFPHP 0.6 w/ Cake 1.2
This is intended as a guide for those out there who *were* using the splendid CakeAMFPHP 0.6.0 with Cake pre-1.2 and want to be able to continue using it in Cake 1.2.
If you have the means to upgrade your gateway, or if you are starting a new project in Cake 1.2, it would be best to use something like CakeAMF (+ amfext) https://trac.cakefoundation.org/amf/ or CakeSWXPHP http://blog.aboutme.be/cakeswxphp/ for your flash/flex remoting needs. I have not used either of these personally though many folks have recommended them to me.
This guide assumes you are starting with:
- Cake 1.2 RC2 (or above will likely work)
- CakeAMFPHP 0.6.0
- AMFPHP 1.9
I would like to thank John David Anderson for helping me get CakeAMFPHP working in Cake 1.2!
Let us begin!
- Edit app/webroot/amfbrowser/config.inc.php, line 75
- Change to App::import('Controller', null);
- Add App::import('Controller', 'App');
- Edit app/webroot/cake_gateway.php, line 75
- Change to App::import('Controller', null);
- Add App::import('Controller', 'App');
- Add require_once(APP.'vendors'.DS.'cakeamfphp'.DS.'amf-core'.DS.'app'.DS."CakeGateway.php");
Download coderequire CORE_PATH.'cake'.DS.'bootstrap.php';After:
loadController (null);
vendor('cakeamfphp'.DS.'amf-core'.DS.'app'.DS."CakeGateway");
Download coderequire CORE_PATH.'cake'.DS.'bootstrap.php';
App::import('Controller', null);
App::import('Controller', 'App');
require_once( CORE_PATH . 'vendors' . DS . 'cakeamfphp'.DS.'amf-core'.DS.'app'.DS. 'CakeGateway.php');
- Edit app/vendors/cakeamfphp/amf-core/app/CakeActions.php, line 195
- Change to $controller->Component->init($controller);
Download code$controller->_initComponents();After:
Download code$controller->Component->init($controller);
- Edit app/vendors/cakeamfphp/amf-core/app/CakeGateway, line 25
Change vendor calls to:
- require_once(APP.'vendors'.DS.'cakeamfphp'.DS.'amf-core'.DS.'app'.DS.'Gateway.php');
- require_once(APP.'vendors'.DS.'cakeamfphp'.DS.'amf-core'.DS.'app'.DS.'CakeActions.php');
Download codevendor('cakeamfphp'.DS.'amf-core'.DS.'app'.DS.'Gateway');After:
vendor('cakeamfphp'.DS.'amf-core'.DS.'app'.DS.'CakeActions');
Download coderequire_once(APP.'vendors'.DS.'cakeamfphp'.DS.'amf-core'.DS.'app'.DS.'Gateway.php');
require_once(APP.'vendors'.DS.'cakeamfphp'.DS.'amf-core'.DS.'app'.DS.'CakeActions.php');
That should wrap things up!
Comments
Bug
1 path problem in step 4
Replace with:
Edit app/vendors/cakeamfphp/amf-core/app/CakeGateway, line 25
Comment
2 cakeswxphp
You should try cakeswxphp - which you mentioned in your post - some time, it contains an amf gateway, and has a branch for cakephp 1.2 :-)
Comment
3 A note about HTTP_RAW_POST_DATA
You should see the following code:
$GLOBALS['amfphp']['actions'] = $this->actions;Just below that, add this if condition:
if (!isset($GLOBALS['HTTP_RAW_POST_DATA'])){
$GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents('php://input');
}
If none of your calls to the service are going through.. this is most likely the problem.
I would suggest the developers of CakeAMF do this to their source because that's how AMFPHP also does it.