AuthorizeNet / sample-code-php

This repository contains working code samples which demonstrate php integration with the Authorize.Net API
MIT License
175 stars 197 forks source link

Doctrine errors related to PHP version #99

Closed mrbobbybryant closed 6 years ago

mrbobbybryant commented 6 years ago

When running the example here: https://github.com/AuthorizeNet/sample-code-php/blob/master/PaymentTransactions/authorize-credit-card.php

I get the following error: Fatal error: Uncaught TypeError: Return value of Doctrine\Common\Annotations\AnnotationRegistry::registerFile() must be an instance of Doctrine\Common\Annotations\void, none returned

It looks like you require goetas-webservices/xsd2php-runtime which then requires jms/serializer which then uses doctrine/annotations.

Dotrine/annotations now requires PHP 7.1. Does that mean that your library will only work in PHP 7.1? I upgraded my version to 7.1 and the process did in fact work. Please let me know if all of the info above is correct. Seems like your docs would need to be updated to say 7.1 instead of 5.6.

Thank You.

adavidw commented 6 years ago

Hi @mrbobbybryant,

Our SDK still only requires PHP 5.6. It's only annotations >=1.5.0 that require PHP7. 1.4.0 works just fine on PHP 5.6 or PHP 7.

When you install our SDK, we always recommend running composer to ensure that the dependency packages are all there and are all the correct versions. I think you already know all this, but for the benefit of all watching, I'll walk through the process here.

In the case of this sample code repo, our composer.json requires authorizenet/authorizenet ^1.9.3. So, running composer update or composer install on a PHP 5.6 installation should install version 1.9.3 of authorizenet/authorizenet. That's the latest release version, and the info in packagist indicates it's appropriate for PHP 5.6.

So, if you're using PHP 5.6 and got doctrine/annotations 1.5.0 installed, something bad happened during that above process. Either you didn't actually use composer to install the dependencies or composer itself somehow fell down on the job, or something else happened.

Some problems I've seen occasionally are that someone will install the sample code repo under one PHP version, but then later move the whole directory to another machine with a different version of PHP and not rerun composer. Another fairly common problem is when you have a different version of PHP on the command line than that run by the web server. If you installed the sample code repo using PHP 7 on the command line, but then attempted to run the samples through the web server (which was using PHP 5.6), you'd run into problems with dependencies with the wrong versions.

Not saying you did any of these things, mind you. Those are just something I've seen occasionally. But, to sum up, there should be no problem running this code under versions of PHP <7.1 as long as you run composer and it does its job.