18 Replies Latest reply on Jan 19, 2010 4:31 PM by uniquehandle

    Tutorial: Flash Builder 4 beta 2 and PHP Data/Services for beginners

    Tom.Krcha Adobe Employee

      Hi fellas,


      I've written this tutorial for total beginners to get quickly to FB4 and PHP. Comments welcome

      Flash Builder 4 and PHP Data/Services for beginners

       

      http://www.flashrealtime.com/flash-builder-4-and-php-data-services/

        • 1. Re: Tutorial: Flash Builder 4 beta 2 and PHP Data/Services for beginners
          uniquehandle

          That's an excellent tutorial, thanks for posting it.

           

          However I can't get past the 'generate sample php service' dialog. Every time, after I've connected to the database and picked the employees table, it crashes before the emp_no pk can be shown. I guess this feature works for some people? The error shows as apache error 6792.

          • 2. Re: Tutorial: Flash Builder 4 beta 2 and PHP Data/Services for beginners
            Tom.Krcha Adobe Employee

            Weird. What's your setup? (OS and surely Beta 2, right?)

             

            Tom

            • 3. Re: Tutorial: Flash Builder 4 beta 2 and PHP Data/Services for beginners
              Tom.Krcha Adobe Employee

              Also are you using MAMP or which server?

              • 4. Re: Tutorial: Flash Builder 4 beta 2 and PHP Data/Services for beginners
                uniquehandle Level 1

                This is windows xp pro, beta 2, xampp. My xampp is a year or two old, maybe that makes a difference. I noticed too that Zend_AMF was added to the project at a later stage of the process than it was in the walkthrough you posted.

                • 5. Re: Tutorial: Flash Builder 4 beta 2 and PHP Data/Services for beginners
                  Gaurav P(Adobe) Level 2

                  Can you please attach a sample database which causes this issue. Also make sure that your xampp server is running on PHP5.x

                   

                  Thanks,

                  - Gaurav

                  • 6. Re: Tutorial: Flash Builder 4 beta 2 and PHP Data/Services for beginners
                    uniquehandle Level 1

                    OK, here is the sql as an export of that db. It's the db which the walkthrough provides as part of the demonstration.

                    • 7. Re: Tutorial: Flash Builder 4 beta 2 and PHP Data/Services for beginners
                      sudhirm-rRcgag Adobe Employee

                      I have tried the same sample on XAMPP 1.7.2 (which uses php 5.3) and its working fine for me.

                      If you are using older version of XAMPP, which does not have PHP 5 or above, things might not work.

                      Could you please try it on latest version of XAMPP and let me know if you are still facing the problem

                       

                      Thanks,

                      Sudhir

                      • 8. Re: Tutorial: Flash Builder 4 beta 2 and PHP Data/Services for beginners
                        uniquehandle Level 1

                        I upgraded my XAMPP to 1.7.2 and now the dialog completes. My XAMPP was 1.7.0 or something like that, def php 5.x, but this made a difference. Thanks!

                        • 9. Re: Tutorial: Flash Builder 4 beta 2 and PHP Data/Services for beginners
                          uniquehandle Level 1

                          Many of us have posted in the original article's comments section that we're getting a "channel disconnected" error. The author of the article has not been able to help us; maybe someone here can? I had that demo app working fine, then suddenly after a couple weeks of not using the app, I get "channel disconnected" whenever I try to run the app.

                           

                          I set up a new virtual server to see if I could get this to work again.

                           

                          Part way through the tutorial I get a new error - after the data service has been created, or configured, the returned data type is not Employees[] as the screenshot shows. Every place that the screenshot shows Employees[] I have Object. I don't know how to adjust that or why this time it didn't automatically show up as expected.

                           

                          This makes the rest of the tutorial impossible to follow. For one thing, I can't set the return type of getAllEmployees() to Employees[]. The app does run to the extent that the list fills and search works. I cannot set up the form, however. Hope someone will provide input.

                           

                          Note, right now at least, flashrealtime.com is running super slow for some reason.

                          • 10. Re: Tutorial: Flash Builder 4 beta 2 and PHP Data/Services for beginners
                            David_F57 Level 5

                            Hi,

                             

                            Its good to see people offering help through tutorials, sadly minimum requirements or explainations of zend requirements are never mentioned. This has been a major issue as zend makes it very dangerous to mix and match apache/mysql/php versions(something that happens in the real world, in zend's world this is irrelevant).

                             

                            What is needed is Zend to put their hand up and offer a full tutorial from the ground up using non zend servers and both local and real world examples.

                             

                            I have attended 2 e-seminars on using  zend with flex, one by zend that was nothing more than a zendserver infommercial and one  by Mihai Corlan of Adobe (http://corlan.org/),

                             

                            Mihai's tutorial is one that can only be regarded with pure respect, it was informative, accurate and covered catalyst/flex/dataservices/zend in a little over 30 minutes flawlessly.

                             

                            As a developer you need to do a few things when there are connection issues

                             

                            1 - only use the latest stable php

                            2 - don't update zend from the one that comes with flex

                            3 - check that the data wizard formed the data services connection properties correctly, sometimes pathing and mysql port are malformed so the gateway gets confused.

                             

                            There are several discussions in this forum that covers some of the problems with zendphp connection issues.

                             

                            David.

                            • 11. Re: Tutorial: Flash Builder 4 beta 2 and PHP Data/Services for beginners
                              Gaurav P(Adobe) Level 2

                              If in some way you land up with the operation return type as Object instead of Employee, you can always right click on the operation and select 'Configure Return Type'. This will allow you to choose an exisiting type or invoke the operation and figure out the return type.

                              • 12. Re: Tutorial: Flash Builder 4 beta 2 and PHP Data/Services for beginners
                                uniquehandle Level 1

                                But, the return type is supposed to be employee[]; and when I did the tutorial in November, that value was in the list. It is not there this time around, and you can't just type "employee[]". And the service operations list that he shows has employee[] as the return type; for me thought it's just object.

                                 

                                I know this is beta software; this issue is almost certainly because the zend or flex stuff has not settled down yet. But I'm hoping that there is some text file somewhere that I can edit so that the return type is offered as it's supposed to be. IE workaround the failings of the wizard stuff.

                                • 13. Re: Tutorial: Flash Builder 4 beta 2 and PHP Data/Services for beginners
                                  uniquehandle Level 1

                                  Re possible path errors etc, what is most curious is that half of the app works. The connection to the db is ok, I can search for records by name and the result set shows up in the flex app. This issue is some wiring problem at a specific point - the return type was not created properly. It was not listed as employees[] as the tuturial shows; just object. I do not think the fb interface offers a handle to that...but surely there must be some text file that if adjusted will fix it.

                                   

                                  I'll look at the completed project that the author offers for download and see if I can figure out where it needs to be adjusted, but if anyone knows where I should look, that'd be great.

                                  • 14. Re: Tutorial: Flash Builder 4 beta 2 and PHP Data/Services for beginners
                                    Gaurav P(Adobe) Level 2

                                    "I do not think the fb interface offers a handle to that"

                                    The way to do this in FB is to use 'Configure Return Type' from the context menu of the operation in Data/Services Panel.

                                    Select one operation which is expected to return Employee. Invoke and name the return type as 'Employee'. For rest of the operations just use existing data type and select 'Employee' instead of invoking in the Configure Return type wizard.

                                     

                                    Also, can you please provide the PHP file which is causing this issue.

                                     

                                    Thanks,

                                    - Gaurav

                                    • 15. Re: Tutorial: Flash Builder 4 beta 2 and PHP Data/Services for beginners
                                      uniquehandle Level 1

                                      I know about that. That is in the tutorial. I'm not sure if you looked at the tutorial, or read my messages carefully here, but what I'm trying to say is that the options in that list are like boolean, boolean[], ByteArray, BytyArray[],...and there is no option in the list for employees[]. There should be. There was the last time I did the tutorial on a different box. And, in the service options dialog ( select the operation, choose properties) the entries all show as type Object. None are employees or employees[] as they should be.

                                       

                                      The question is, since as far as I can tell the wizard that created the data service didn't quite work as expected, how can I manually reconfigure the service to offer employees[] and not plain objects. I may be able to figure it out, but if anyone knows please clue me in.

                                       

                                      Thanks

                                      • 16. Re: Tutorial: Flash Builder 4 beta 2 and PHP Data/Services for beginners
                                        David_F57 Level 5

                                        Hi,

                                         

                                        The first issue will be the pathing differences between wamp/mamp/xampp, some use www as root others htdoc you need to setup the php services on your local machine rather than importing a project.

                                         

                                        The created services will have a connection array declared at the top of the code that points to the mysql server, in the project default debug folder you will have the config file that has the zend and webserver path

                                         

                                        top of service file

                                        ============

                                        var $username = "root";

                                        var $password = "";

                                        var $server = "localhost";

                                        var $port = "3306";

                                        var $databasename = "zend";

                                        var $tablename = "clients";

                                         

                                        var $connection;

                                         

                                         

                                        amfconfig.ini

                                        =========

                                         

                                        [zend]

                                        ;set the absolute location path of webroot directory, example:

                                        ;Windows: C:\apache\www

                                        ;MAC/UNIX: /user/apache/www

                                        webroot =C:/wamp/www

                                         

                                        ;set the absolute location path of zend installation directory, example:

                                        ;Windows: C:\apache\PHPFrameworks\ZendFramework\library

                                        ;MAC/UNIX: /user/apache/PHPFrameworks/ZendFramework/library

                                        ;zend_path =

                                         

                                        [zendamf]

                                        amf.production = false

                                        amf.directories[]=Zender-debug/services

                                         

                                        In your main project folder you have a .model folder the file there is an *.fml file that contains your channel endpoints etc.

                                         

                                         

                                        David.

                                         

                                         

                                        • 17. Re: Tutorial: Flash Builder 4 beta 2 and PHP Data/Services for beginners
                                          uniquehandle Level 1

                                          Thanks David. But doesn't the fact that the project is able to query the db and return a list mean that it's basic path port etc stuff is ok? I'd guess so.

                                           

                                          The 'fault' is apparent at the end of the data service config, when the service operation dialog presents the list of operations and return types. The return types are all Object. They are supposed to be employees or employees[].

                                           

                                          Doesn't it seem like somehow the zend package is the issue? I'm using the zend that comes with fb beta 2.

                                          • 18. Re: Tutorial: Flash Builder 4 beta 2 and PHP Data/Services for beginners
                                            uniquehandle Level 1

                                            I hope someone can give me some input on this...