Closed DaveChild closed 10 years ago
It looks like the problem is this code (line 42 in PPRestCall):
$handler = new $shandler($this->apiContext);
This is passing the apiContext as the first param to the constructor of the handler. The hander is \PayPal\Rest\RestHandler, and expects the sdkName as a string as the first param.
The plot thickens ... there are two versions of PayPal\Rest\RestHandler, one on vendor/paypal/rest-api-sdk-php and one in vendor/paypal/sdk-core-php, and they are different. The order of loading is controlled by the autoloader, which gives two entries for the Paypal namespace:
'PayPal' => array($vendorDir . '/paypal/sdk-core-php/lib', $vendorDir . '/paypal/rest-api-sdk-php/lib),
If I swap these over, it all works. But doing this for every installation manually would seem crazy.
@DaveChild Thank you so much for the information. This really helps. I will definitely look into this issue, and get back to you soon.
Thank you for the information you provided. Really helps.
Shouldn't the 2 packages have 2 completely separate namespaces? ie: PayPal/Rest/Rest/RestHandler and PayPal/Core/Rest/RestHandler?
@DaveChild @SamMousa I am trying to see if I could completely eliminate the duplication and unnecessary distribution of files in two different packages. It would make a much better experience to clean up the code. I am working on it soon, and would resolve similar issues in future. Thank you so much for your suggestions btw.
@jaypatel512 @DaveChild
For anyone still having trouble with this, I managed to circumnavigate the OP issue
Object of class PayPal\Rest\ApiContext could not be converted to string...
...by changing bootstrap.php so that it doesn't pull the project root autoloader, but uses the 'rest-api-sdk-php' vendor dir:
//$composerAutoload = dirname(dirname(dirname(__DIR__))) . '/autoload.php';
$composerAutoload = null;
This triggers the file_exists fallback block and makes proper payments on my sample files.
@DaveChild I just made a release that merges the sdk core package, and uses it only as a part of the package. As we were supporting older SDKs along with REST, the reason for keeping was valid. However, as the other dependencies are invalidated, we made the decision to merge the rest sdk into one package.
This release should resolve such issues. Please re-open this bug if are still able to reproduce the issue.
@DaveChild Thanks for the detailed information again.
@DaveChild @alymdrictels guys, take a look at my answer in different thread mentioning the same error message, maybe it will help: https://github.com/paypal/rest-api-sdk-php/issues/121
I get the following error running the sample code on PHP 5.5.3
If I hard code the SDK name to 'rest-sdk-php' in RestHandler.php, line 59, it seems to work.
Including the SDK via Composer, and nothing else unusual going on. Happy to provide any more info if it'll help.