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. Avatar of lexa


    April 25, 2012

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

  2. Avatar of Ariel Sommeria-Klein

    Ariel Sommeria-Klein

    April 25, 2012

    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. Avatar of ragav


    May 16, 2012

    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.

Add a comment

You must be logged in to comment.

Sign up for Silex Labs news by email

Follow Silex Labs on twitter