4 Replies Latest reply on Aug 11, 2009 2:32 PM by Jens Wegar

    Can gateway.php location be changed in Flash builder project?

    Jens Wegar Level 1

      Hey,

       

      I have a project in the works where it is necessary to separate the PHP parts and Flex parts into their own projects in Eclipse/Flash Builder. This is so that a PHP developer can work on the server side code while I work on the Flex side of things. It's also for a clearer separation of the two areas (the gateway is supposed to be usable for several Flex projects, not just this one project).

       

      I'm loving the Data / Services wizard, but I would like to be able to tell it to generate it's PHP code into another location on the file system. This would also mean that the gateway.php location should be another than the default bin-debug. If I do this manually (i.e. generate the service classes and them move them to another project), introspection fails with an "Failed to include" message because Flash builder apparently only has that one location where the gateway.php lives. I know I can go into properties->Flex Server and change the output folder, but that means that all the Flex related files are copied to the PHP project also, which is not something I want.

       

      Any suggestions on how I could change where the PHP files are generated? I don't mind a hackery solution for the time being, but it would be cool if the final build of FlashBuilder would allow you to set the PHP output location separately and not assume that the services want to live in a subfolder of the Flex application.

        • 1. Re: Can gateway.php location be changed in Flash builder project?
          Gaurav P(Adobe) Level 2

          Hi,

          Great to hear that you are loving the Data Centric features!!

          The PHP wizard allows the user to import php files from any location in the web-root, simply browse to that location.

          Also, while generating you can choose the location where you may wish to generate the sample php file by unselecting the default location checkbox.

           

          Regarding the gateway.php file, as you pointed out the file is generated in the output folder. Also, if you notice there is another file 'amf_config.ini' generated at the same location.

          The amf_config.ini file stores the location of all the directories which contain the imported/generated service php files. Note that the location of the directories are relative to the amf_config.ini file location.

          During the runtime the application calls the gateway using a url like : http://<yourserver>/<outputfolder>/gateway.php

          Also, Flash Builder uses this url for introspection.

           

          The gateway.php file cannot be moved during development. But once the development is done you can move it to any location in the web-root.

          Note that the gateway url is hardcoded in the Super<Service>.as file as _serviceControl.endpoint = http://<yourserver>/<outputfolder>/gateway.php .You can move the gateway.php file to any location but will have to copy the amf_config.ini file to the same location. The amf_config.ini file will have to be modified to point to right service directories relative to its location. Also you will have to modify the <Service>.as file by changing the serviceControl.endpoint to the new location url of the gateway.php file.

           

          Hope this helps.

           

          Thanks,

          - Gaurav

          1 person found this helpful
          • 2. Re: Can gateway.php location be changed in Flash builder project?
            Jens Wegar Level 1

            Thanks for the quick reply. I could live with having the gateway.php remain inside the flex project since that one seems to be generated only once. The ini file is probably re-generated each time a new service is added (especially if it's in a new package), so that would have to be copied again each time a new service is added?

             

            Unfortunately, there seems to be a bug in the Configure PHP Service wizard which makes it impossible for me to generate the services in any other folder than the bin-debug folder of the Flex project. Hoping someone else could confirm it before I file it?

             

            Steps to reproduce:

             

            1. In the Data/Services tab, click on Connect to Data/Service

            2. Choose PHP

            3. Enter service name, select "Generate sample PHP class"

            4. Uncheck "Use default location", choose any folder that is not the bin-debug/services folder in the Flex project

            5. Click Finish

             

            I get the following error:

            There was an error during service introspection.
            <br /><b>Warning</b>:  Zend_Loader::include_once(TestService.php) [<a href='function.Zend-Loader-include-once'>function.Zend-Loader-include-once</a>]: failed to open stream: No such file or directory in <b>/Users/jenswegar/Documents/Development/ZendFramework/library/Zend/Loader.php</b> on line <b>135</b><br /><br /><b>Warning</b>:  Zend_Loader::include_once() [<a href='function.include'>function.include</a>]: Failed opening 'TestService.php' for inclusion (include_path='services/.:WebServicePHP/services/.:.:/Applications/MAMP/bin/php5/lib/php: /Users/jenswegar/Documents/Development//ZendFramework/library') in <b>/Users/jenswegar/Documents/Development/ZendFramework/library/Zend/Loader.php</b> on line <b>135</b><br />

            • 3. Re: Can gateway.php location be changed in Flash builder project?
              Jens Wegar Level 1

              The last part of my previous post was cut off, here's the rest:

               

               

              My setup:

               

              MacBook Pro 2.33GHz (2006 model)

              OS X 10.5.8

              Eclipse 3.4.2

              Flash Builder Beta plug-in (version 4.0, build 235740)

               

               

              Note however that the PHP file has been generated in all cases. It seems it's just the introspection that fails.

               

              So it would seem you can choose any location you want as long as it's the default location, which kind of negates it's use. I attached a set of eclipse projects in case it helps.

              • 4. Re: Can gateway.php location be changed in Flash builder project?
                Jens Wegar Level 1

                I found a workaround for the bug. It requires some manual editing of the amf_config.ini and some dummy service creating.

                 

                Steps:

                 

                1. In a clean project (i.e. one with no services added yet), go to the Data/Services view and choose "Connect to Data/Service"
                2. Choose PHP
                3. Create a Temporary service (I called mine FakeService) with the default settings and choose Finish. Let the generator do it's magic.
                4. In the bin-debug folder, open up the amf_config.ini file and copy the line that says amf.directories[] = services
                5. Paste the line onto the next line. Flash builder might notify you that you are editing a derived file. Just click yes here.
                6. Change the services part to reflect the relative path of the folder where you really want your PHP files to live. In my case it was ../../WebServicePHP/services. The path is relative to the ini file. Save the changes to the amf_config.ini file.
                7. Right click on an empty area in the Data/Services view, choose Connect to PHP.
                8. Enter the name of a service you want to create, choose generate Sample PHP class
                9. Uncheck the "Use default location" checkbox and browse to the location that you entered in the amf_config.ini. Create any folders you may need to create to match the path in the .ini file (e.g. In my case I had to create the WebServicePHP/services folder)
                10. Click Finish. The PHP file is created in the correct location and introspection still works. You can now delete the FakeService if you want to. New services can be created outside the project folder also. If you create a new package for a service, you only need to repeat steps 4-10. The FakeService only needs to be created the first time so that the gateway.php and amf_config.ini files are created.