Creating Flex Mobile Apps with Flash Builder for PHP

As you might have heard, we released earlier this week Flash Builder and Flex 4.5. Part of this release is a new product called Flash Builder for PHP 4.5. This is something you should make sure you try if you are a PHP and Flash/Flex developer.

So what is Flash Builder for PHP? This product will install Flash Builder 4.5 with Zend Studio 8.1 as a plugin plus some additional plugins that integrate these two products. Using this IDE you can create mixed projects (Flex and PHP both for desktop and mobile devices) and you can streamline testing, deploying, debugging, and consuming PHP services via Flex remoting (with the help of Zend Framework).

Instead of writing a pretty long article, I decide to shoot a video tutorial on how you can create a Flex mobile app that uses a PHP service. This tutorial will walk you through:

  • Using the new project type Flex Mobile and PHP
  • Creating a mobile application that has two views/screens. I will explain how to use the ViewNavigator and View classes to control your application state
  • Consuming a PHP service from a Flex mobile app using remoting
  • Testing and debugging the code (Flex and PHP) on the desktop simulator and physical device

I hope you will enjoy this. If you want to download the files used for this tutorial, click here (unzip the file and you will get the Flex project you can import it and the PHP files plus the database dump).

31 thoughts on “Creating Flex Mobile Apps with Flash Builder for PHP

  1. Hi Mihai

    Very nice, but what’s the difference between Flash Builder for PHP and Eclipse Plug in ?? I imagine just Zend Studio and Eclipse PDT, right ?

    Thanks !!

  2. HI Armando,

    There is more in this integration than just Flash Builder and Zend Studio. There are additional plugins that enable:
    – the Flex and PHP project types
    – unified debug perspective for both Flex and PHP code
    – configuration for running/debugging projects
    – and others

  3. Thanks Mihai

    I’ll give it a try, I currently use Flash Builder Plugin In. And I’m looking the upgrade options.

    Thanks again !

  4. I already own a copy of Zend Studio 8 and Flash Builder 4.5 Premium. Is there a way to integrate the two together to give me the same functionality as Flash Builder for PHP 4.5 including the plugins?

  5. @Jason Hebert

    It is not possible. There are additional plugins that make the integration…

  6. Hi Mihai, great tutorial! thanks for share your knowledge. I have a question, how could you update the app data in real time from a website? thanks!

  7. @Xirka

    You can use polling (makeing requests to the website every second).

    there are different methods depending on what you have on the server.


  8. Thank you so much Mihai. I’m using Flash Builder for PHP. Which do you think is the easiest method to start? Thank again for your help!

  9. Xirka – check out my class at Udemy…introduces flex mobile from scratch…then you’ll be ready for this great vid from Mihai.

  10. awesome tutorial. I am new to flash builder but I was able to follow the tutorial and get this app to work.

    my question is…things are working great on local machine but what do i need to do to get this app to work on my remote server with remote mysql. i.e. do i need to move files to my hosting company server. how will the app find the file like gateway.php or employee.php.

  11. @binary

    You’ll have to move to your server the PHP files including the Zend Framework and the gateway.php file. Next, in the Flex mobile app you will have to change the URL from localhost to your server real IP.

    I agree that this step is not straightforward as it could be. Maybe I will write a tutorial.


  12. Thank you so much Mihai for your quick response. The tutorial will be a big help. I am looking forward to it.

    I was able to get the remote mysql (using IP address) to talk to my local application and get the application to work. When i upload the php service folder from flash builder to server, and do a test operation in flash builder, i get the following message..InvocationTargetException:There was an error while invoking the operation. Check your operation inputs or server code and try invoking the operation again.

    Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /homepages/24/d147393763/htdocs/mobile/gateway.php on line 35

    line 35 relates to “Zend/Loader/Autoloader.php”…so I uploaded the file to server too…but no luck.

    looking forward to your help and tutorial.

  13. Hello Mihai,

    Thanks you very much for your tutorial. :)

    I will appreciate you if you write a tutorial how can we run this in server instead of local machine.

  14. Pingback: How to set up FB4.5 for PHP without using Zend Server? | Coders & Admins

  15. Hello Mihai,

    Thanks you very much for your tutorial.

    the problem I face is not show anything when press the “Go”, if you can help me.

    I wear a webserver: XAMMP for windows

  16. hi Mihai, how are you?
    The example is working, but now i want do operation in another table the database, for example “user”.
    I need create another file User.php and VOUser.php to connect to new table or i can use the Employees.php and VOEmployee.php.

    I try 2 ways but don’t work… i dont know why!

    Best Regards
    Filipe Duarte

  17. @Filipe Duarte

    Normally you’d have a service for each table and a VO for each table.


  18. @Filipe Duarte

    If you placed your files in the same folder as the Employees/VOEmployee you shouldn’t do anything else.

    Make sure you don;t have errors in your PHP files.


  19. I have to gotten this tutorial to work on my local mac webserver with the default install, but I am having trouble deploying it to a ubuntu webserver 11.04 and knowing which config files to change. The default web root in ubuntu is var/www and I copied my Project Folder to that location and set up the sql table so that’s working. This is the best tutorial I found explaining PHP and Flex integration, thanks so much!

  20. Hi Mihai…
    i try your source and i get log php erro when add some data to employees table :

    PHP Fatal error: Call to undefined method PDOStatement::lastInsertId()

    * @param VOEmployee $item
    * @return VOEmployee
    public function createItem(VOEmployee $item) {
    $stmt = $this->_pdo->prepare(“INSERT INTO employees (first_name, last_name) VALUES (:first_name, :last_name)”);
    $stmt->bindParam(‘:first_name’, $item->first_name, PDO::PARAM_STR);
    $stmt->bindParam(‘:last_name’, $item->last_name, PDO::PARAM_STR);
    $item->emp_no = $stmt->lastInsertId();
    return $item;

    the event result never work… all time event fault

    the data record in table… but show this erro in log php and event result never work.

  21. I found the problem…
    change the line:

    $item->emp_no = $this->_pdo->lastInsertId();

    now the event result is work!


  22. Hi, could you explain how to attach a busyIndicator while the service call is being made to display progress, the example works well


  23. Pingback: Cross-Platform Mobile Code Generator – a Tool Comparison « Technology Trend Analysis

  24. Hi ,Thanks for tutorials . Iam trying to get output but error – Reason:
    Notice: Undefined variable: ret in C:\Program Files\Zend\Apache2\htdocs\MobileFlex\services\Employees.php on line 48

    Can u help me ..

  25. thnks Mihai Corlan for ur tutorial i have a question how i can integrat a map with my Mobile Apps with Flash Builder for PHP

  26. thnks Mihai Corlan for ur tutorial i have a question how i can integrat a map with my Mobile Apps with Flash Builder for PHP ?

  27. Hi, Thanks for this tutorial it has helped me lots, I am now trying to create a login system as well and I can not get the data entered into a text box to be entered into the database, I can seem to create a link between the text box and the php file. Do you have any clue how to approach this? It is for my final year project at university and it is due on Friday!

    Any help will be greatly appreciated!

  28. You Sir, are a hero!
    I have just built my first project app based on your step by step guide.
    just want to say thanks.

Leave a Reply