0
votes

I have a simple configuration for Flex project ( with WAMP server connected and AMFPHP included ). And everything seems to work, I can call simple PHP class methods from Flex and retrieve the returned data.

But then I have this little problem. I am using additional PHP library, which uses the relative paths to include or find another files. So here is a simplified Amfphp/Services/ directory:

  • Services
    • MyExampleService.php
    • lib
      • MainLibraryFile.php
      • classes
        • LibraryGlobalClass.php
      • wsdl
        • LibraryGlobalService.wsdl
      • etc
        • LibraryConfig.php

Then after some MainLibraryFile work, the LibraryGlobalClass.php wants to read LibraryGlobalService.wsdl. It is constructed the way, that the path to the wsdl's directory is saved in LibraryConfig.php, so the GlobalClass first reads the path to the wsdl's from Config file, and then concatenate it with the name of the Service wsdl file name.

It looks something like this:

In LibraryConfig.php :
public $ConfigPathToWsdl = "../wsdl/";  

In LibraryGlobalClass.php :
$this->config = new LibraryConfig();
$this->ReadWSDL( $this->config->ConfigPathToWsdl . "LibraryGlobalService.wsdl" );

And it seems that this two dots ( parent directory ) do not work the same way in this Amfphp call. It is not going from etc dir to lib dir ( via .. ) and then to wsdl dir, instead it creates some crazy link that cannot be resolved.

I wonder if there is a way to change it somehow, or I am just missunderstanding something.

1

1 Answers

0
votes

Best practice is to use absolute paths, not relative. How about replacing $ConfigPathToWsdl by something like dirname(FILE) . '/../wsdl' ? Note it's FILE surrounded by double underscores, as shown here in the comments here http://php.net/manual/en/function.dirname.php