Sencha Touch 2 and amfPHP2

Posted by

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

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’
method: 'POST',
url: ‘’,
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’]}

method: 'POST',
url: ‘’,
params: JSON.stringify(myParams);


  1. lexa

    25 Avr 12

    Excellent article
    Very promising method for JS/PHP app for mobiles
    At last some people use amfPHP with JS on the client side

  2. ariels

    25 Avr 12

    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

  3. ragav

    16 Mai 12

    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.

  4. ariels

    16 Mai 12

    in your config you provide several service folders.

Comments are closed

News letter

Evénements Silex Labs sur Paris et sa région: Inscrivez vous à la Newsletter mensuelle

Silex Labs community Tweets

Facebook page