Mathieu Decoene @Coenego here shares some insights on using Sencha Touch 2 with amfPHP 2
For those who don’t know Sencha Touch: it’s a javascript framework for mobile (based on Sencha
Ext).
It’s always a bit trial and error when new updates are released; new methods, deprecated stuff… I’m
talking about Sencha Touch 2 and amfPHP 2 in this case.
Since we’re talking about mobile apps, Ajax-requests are basically used to receive or send our
data (because we want it to run behind the screens). So, amfPHP is a perfect partner for
communication between Sencha Touch (or any other client framework) and the services.
But some things have changed since boths v1’s… For example: You don’t have to specify your service and
method name any longer in the url-property (to which the request is sent) of the Ajax-request. Now
you have to add both names as a property value together with the other parameters.
Examples of usage:
consider this amfPHP service:
<!--?php class MyService{ function myMethod($data){ // do something with property1 } } ?-->
To call it from Sencha Touch when running it in amfPHP v1, do the following:
var myParams = {
property1: ‘value1’,
property2: ‘value2’
};
Ext.Ajax.request({
method: 'POST',
url: ‘http://www.yoururl.com/amfphp/json.php/MyService.myMethod’,
params: myParams
});
?>
To call it from Sencha Touch when running it in amfPHP v2, do the following:
var myParams = {
serviceName: 'MyService',
methodName: 'myMethod',
parameters: [
{'dataroot': [‘value1’,’value2’]}
]
};
Ext.Ajax.request({
method: 'POST',
url: ‘http://www.yoururl.com/amfphp/?contentType=application/json’,
params: JSON.stringify(myParams);
});





lexa
Excellent article
Very promising method for JS/PHP app for mobiles
At last some people use amfPHP with JS on the client side
Ariel Sommeria-Klein
they’ve been doing it for a long time, it’s just that most people don’t know about it yet. This post should help raise awareness
ragav
Good post, I have few doubts. How can I have different classes in different folders as in amfphp1.9? And please provide some standard coding samples.
Ariel Sommeria-Klein
in your config you provide several service folders.