Steps to deploy a Flex and PHP application

I’ve been receiving a number of emails on this topic lately. It seems there is little information out there about how to move from development to production with a Flex and PHP application. Here is a simple checklist that could help you, especially if you are doing this for the first time. Please note that I presume you used the Data Services (wizards) to connect the Flex client to PHP services.

  1. Make sure you have Zend Framework on your server. If you don’t, install it
  2. Make sure you change MySQL credentials and server IP/name used by your PHP scripts to connect to the database
  3. Copy the PHP services folder to your server. Then test these services. If they don’t work check the MySQL credentials or look for dependencies (maybe your PHP services use other PHP classes that you forgot to copy to your server)
  4. Edit the amy_config.ini file and make sure the path to the Zend Framework is OK and set production to true
  5. Edit the Flex services to point to your live server gateway.php. In the services folder of your Flex project you will find _Super_something.as files. In the constructor you will find a line like this:

    _serviceControl.endpoint = “http://localhost:10088/MobileFlexPHP-PHP/public/gateway.php”;
    Copy that line and then open the class that extends this _Super class and paste the line in the constructor. Then change the URL to reflect your server setup

  6. Copy the bin-release/ folder to your server (you should choose the export release for your project; this will create a SWF file smaller than the debug version)

That’s it! If I missed something please drop a comment!

14 thoughts on “Steps to deploy a Flex and PHP application

  1. I use flex for php and don’t understand that :

    In the constructor you will find a line like this (you have change this to reflect the server path)

    All _Super_xxx_.as are not intended for modification.

    In the projet propeties we have a flex Server configuration tool and flex/php support, what is the difference ? Which one should I use to deploy ? What the default configuration for flex/php support is not valid for flex server ?

    In flex server I can change the root url. If I want to put the final server path (distant) I don’t konw what I have to put in Web root and output folder. I’ve already delpoy php, I just want an air app which use the right path.

  2. @lgerber

    You are right with the all _Super_xxx. I meant the class that extends the _Supper. I updated the post to reflect that.

    For AIR applications you will have to update the services URL to use absolute URLs. So I suggest to do this using the same approach I explained in my post. Flex services panel doesn’t support external PHP server setups.

    cheers,
    Mihai

  3. Hi Mihai, how can i securize this webservices? What about webservice authentication present in Flash Builder wizard? Have you ever used it? How? Thanks

  4. Hi,

    thanks for the steps. I want to deploy a Flex 4 web application with php onto a remote headless Ubuntu Linux server which does not have Zend installed but it already has MySQL and php installed. I’ve been developing on my Windows XP machine using a WampServer and developing in FlashBuilder 4. Must I install the Zend stack even though it already has MySQL and php? Before hacking into the server, I thought as a trial to try & install Linux and MySQL and php (or Zend) on an external hard drive & see if I can get a release version of the Flex web app first onto that. Do you think that’s a good idea? Thanks.

  5. Thanks a lot for this post. Its something I have been looking for.

    I have done as you have instructed but i get the following error:

    Send failed
    Channel.Connect.Failed error NetConnection.Call.BadVersion: : url: ‘http://ipaddress/site/public/gateway.php’

    Am I doing something wrong? Thanks

  6. I’m so frustrated with deployment of flex/php using Flash Builder 4.5.1. I’ve worked through most of the problems in deployment. I completed step 5 above and no longer got the #2048 error but now I get nothing but a blank alert box with an ok button and my app is still not connecting to data.
    Any ideas as to why this happens? I can reach my endpoint. My amf config and gateway seem to be correct.
    What would be nice if some tutorials would be done beginning to end showing deployment and folder structures. It seems every Adobe tutorial I look at is done differently.
    Thanks for any help you can provide.

  7. Hi khristi,

    I’m sorry to hear about your problems. Unfortunately, there isn’t possible to write a complete guide for deploying Flex and PHP apps. Why? Because most of time the errors people are encounter are related to:
    – incorrect database user, password, or server;
    – files not copied to the server;
    – Flex app compiled with different server URL;
    – and so on.

    cheers,
    Mihai

  8. thanx a lot!

    i am having trouble connecting to the gateway.php
    all my code is generated with FB 4.6 wizards and i followed your steps to modify the stuff, but my app can’t connect and displays:

    Send failed
    Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Status 501: url: ‘http://(my domain and app)/gateway.php’

    can you tell what is going on?
    thanx
    Saar

  9. I need help!!!!!!

    I’m new to Zend PHP with Flex 4.6. I use Flex 4.6 at work but with Java Webservice and DS.

    But now at a home project I was trying to use Zend and Flex 4.6 Data Services (wizards) to connect the Flex client to PHP services. It works grate on my server but from the out side I’m getting error: Send failed
    Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Status 403: url: ‘http://mydomain/gateway.php’

    here is my crossdomain.xml

    Can someone help me!!!!!

    Thanks
    Stan

  10. allow-access-from domain = *
    site-control permitted-cross-domain-policies = all
    allow-http-request-headers-from domain = * headers = *

  11. Hi there,
    I am also a rookie of Flex. Recently,I try to learn it with the Adobe’s tutorials which locals on: http://www.adobe.com/cn/devnet/flex/testdrive/articles/2_modify_the_database.html#links
    However,when I attempt to add some employees as the tutorial says,there always be an error:
    Channel disconnected
    Channel disconnected before an acknowledgement was received
    Even though I searched for the solution a lot times,I haven’t find a appropriate one.
    It bothers me several days
    So, if you guys knew how to figure it out , please do me a favor.
    Thanx a lot
    Nick

  12. hello Mihai again and thank you

    regarding step 5: can i make the url relative to the swf on the server?
    I want the different instances of the same app to access different databases based on location in server

    thanx
    Saar

  13. I love you. (I would have loved you more about 4 hours ago when I started looking for the solution!)

Leave a Reply

Your email address will not be published. Required fields are marked *