Apr 02, 2009

CpAmf php example

by: Daniel Verner

Introduction

This test application is made to present the usage of CpAmf plugin for cakePHP 1.2. 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.

Requirements

  1. CakePHP 1.2
  2. CpAmf plugin (included in package)

Introduction

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

Installation

Just copy the cpamf_test folder to your web server's htdocs directory. To check the gateway installation, simply open the following url:
localhost/cpamf_test/cpamf/gateway.

You should see a message like this:
amfphp and this gateway are installed correctly.
You may now connect to this gateway from Flash.


If you have the amf extension you shuld see this in message:
AMF C Extension is loaded and enabled.

Create a mysql database. Set up connection parameters in config/database.php file. The sql file for the users table is included in this package (cpamf.sql).

Using the service browser

The service browser is accessible at following url:
localhost/cpamf_test/cpamf/browser.

NOTE: In this test application you can use the UsersController class, and the following methods:

  • getUser
  • getAllUsers
  • insertUser
  • test

Download

Download the example here.

See also

CpAmf flex example.

Share this post:

8 comments

Benjamin Müller

Benjamin Müller

hej, thank you for this great plugin description. Unfortunately, when I tried to create an app on my own, it does not work. I used bake to create a project and bake all to insert models and controllers. Then I installed the plugin and my cpamf/browser works so far, BUT if I click on one of the Controller on the left side there is a failure message "Service does not contain any methods". But there are some methods ( eg auto generated ones). Ideas?
thank you, benny

Sep 30, 2009 (13:34:55) - #1
web 2.0 development company

web 2.0 development company

thanks for sharing information & having really informative . .

Nov 09, 2009 (12:10:44) - #2
Daniel Verner

Daniel Verner

@Benjamin Müller
Check the method prefix in /cpamf/vendors/amfphp/globals.php ( define( "METHOD_PREFIX", "prefix" );). If it is set, then the service browser only shows methods beginning with this prefix. If you want to see all methods set this const to empty string.
You shold use the latest version of the cpamf plugin(v0.12)

Nov 12, 2009 (09:02:28) - #3
Roel

Roel

Hi,

Thanks for the great plugin. I had the same problem as Benjamin. After some research I managed to fix it (as far I can see). It came down to this:

In 'discovery_service_controller.php' (line 89) use Inflector::underscore on $classname. Then in 'CakeMethodTable.php' (line 42, 46) remove Inflector::underscore. This way it won't be applied on the whole path. At last I added the suffix 'Controller' on line 50. This way the right class will be found in with MethodTable::getClassMethodsReflection() ()

Nov 27, 2009 (18:06:54) - #4
Roel

Roel

Uhm.. ignore that last edit. Adding the suffix was a mistake.

Nov 27, 2009 (19:09:02) - #5
Itziar

Itziar

Hi,

Thanks for the information. But I have an error with the service browser.

When I access to the following url http://localhost/cpamf_test/cpamf/browser I get this error.

(mx.rpc::Fault)#0
errorID = 0
faultCode = "Client.Error.MessageSend"
faultDetail = "Channel.Connect.Failed error NetConnection.Call.BadVersion: "
faultString = "Send failed"
message = "faultCode:Client.Error.MessageSend faultString:'Send failed' faultDetail:'Channel.Connect.Failed error NetConnection.Call.BadVersion: '"
name = "Error"
rootCause = (Object)#1
code = "NetConnection.Call.BadVersion"
description = ""
details = ""
level = "error"

what the problem might be?

Thank

Itziar

Dec 04, 2009 (14:42:30) - #6
Rajib Ahmed

Rajib Ahmed

I was trying to work with this plugin for three days. The first problem that Bugged me for a while that in cakeMethodTable.php in create method that generated bullshit path through camelize ie CakeAMF ... becomes c_a_m_f directory that not cool. then i am using php5.3.1 so eregi_replace function on MethodTable.php doesn't work have to rewrite 2 line as
// $comment = eregi_replace("\n[ \t]+", "\n", trim($comment));
--to--
$comment =preg_replace("/\n[ \t]+/", "\n", trim($comment));

//$comment = eregi_replace("[\t ]+", " ", trim($comment));
--to--
$comment = preg_replace("/[\t ]+/", " ", trim($comment));

then the demo works fine which is built on top of cpamf 0.9

if you need any help go to my site then post a comment .. I ll try to reply

Mar 18, 2010 (13:22:16) - #7
Paul Man

Paul Man

This plugin is not working with cakePHP 1.4 RC4
Missing Controller
Error: GatewayController could not be found.

Error: Create the class GatewayController below in file: app\controllers\gateway_controller.php

help please!!

May 18, 2010 (13:12:30) - #8

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