1
Vote

Generating of PHP wrapper failed on a UNIX/LINUX system

description

Once installed, the first attempt at generating the PHP wrapper failed with the following error message:
PHP Warning: require_once(Resource\Messages.php): failed to open stream: No such
file or directory in /etc/php5/phplib/ODataphp/Common/ACSUtil.php on line 19
PHP Fatal error: require_once(): Failed opening required 'Resource\Messages.php'
(include_path='.:/etc/php5/phplib/ODataphp') in
/etc/php5/phplib/ODataphp/Common/ACSUtil.php on line 19
This happens because the PHP files provided have "\" instead of "/" in their path calls. On a
UNIX/LINUX system, these must be changed. In the "./Common/ACSUtil.php" file, the
“require_once” block was converted to the following:
require_once 'Resource/Messages.php';
require_once 'Common/Collection.php';
require_once 'WebUtil/HttpVerb.php';
require_once 'WebUtil/HttpRequest.php';
require_once 'WebUtil/Microsoft_Http_Response.php';
require_once 'WebUtil/HttpResponse.php';
require_once 'Common/HttpProxy.php';
require_once 'Exception/ACSUtilException.php';
require_once 'Exception/InvalidOperation.php';
Once this is complete, the wrapper is generated and stored locally. However, the offending slashes
exist in the code used to generate the wrapper php as well causing it to not output the filename and path
correctly.
Using the following:
php /etc/php5/phplib/ODataphp/PHPDataSvcUtil.php
/uri=https://RFCWEBDIR:t4ZGpdkp@ngp.olemiss.edu/sap/opu/sdata/sap/CAMPUSDIRECTORY/
/out=/home/christopher/CAMPUSDIRECTORY.php
The resulting file created was written in the folder "/home/" with the name
"christopher\CAMPUSDIRECTORY.php". We then were able to rename this file and move it to the
appropriate location.

file attachments

comments

xrow wrote Jan 30, 2012 at 3:44 PM

Hey there,

you can solve it with DIRECTORY_SEPARATOR, e.g.:

require_once 'WebUtil'.DIRECTORY_SEPARATOR.'Microsoft_Http_Response.php';

raphie wrote Dec 13, 2012 at 6:41 PM

I found this problem too and it caused because all the require_once references point to the root of the library, not the suggested ODataphp folder inside the php library folder.

Solution one:
Make sure you added the ODataphp_path variable to the php.ini file:
; OData PHP SDK library path
ODataphp_path = "d:/location/of/your/php/odataphp/library"
;it case sensitive in the SDK I guess.. so make sure is ODataphp_path exactly

If this doesn't fix the problem...

Solution #2:
What I did to fix this problem was creating an Environment Path "ODATAPHP" value "D:\Location of your\php\library". This because the ODataphp_path variable set in the php.ini file was not returning any value in the code when tried to access through ini_get("ODataphp_path"), always returned empty.

For Apache, get the httpd.conf and add:
setEnv ODATAPHP "d:/location/of/your/php/odataphp/library"

If you don't have access to this files or your not able to reset your server then you need to define a global variable pointing to the URL of your library (Just assumption haven't test it):
define("ODATAPHP","d:/location/of/your/php/odataphp/library");

Then you have to add the varible to the Code... create a project pointing to your odata php library and search for every require_once() instance and add:
$_SERVER['ODATAPHP']."/Common/blahblah.php", remember to add to forward or back slash (Windows)

With define() use:
ODATAPHP."/Common/blahblah.php"

That should fix the problem. It works for me and I hope this help. I attached my modified version. (Have in consideration that I'm using Windows Server, if you in Linux you might need to change the backslashes in the php code)