cancel
Showing results for 
Search instead for 
Did you mean: 

PHP SDK: Fatal error - running sample code.

I am getting the following exception when trying to run sample PHP charge-credit-card.php code. 

 

 

Not sure what's going on. What this error is about? 

Here is the screenshot of error. 

https://www.screencast.com/t/cTU6gglqQS

 

Here is the code which I am using. 

 

https://github.com/AuthorizeNet/sample-code-php/blob/547daabc90ff0f579530d6e5295c02d52e27b257/Paymen...

2017-07-26_0509
Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.
1 ACCEPTED SOLUTION

Accepted Solutions

It appears that newer versions of Doctrine Annotations are using a void return type that wasn't introduced until PHP 7.1, thus causing that error.

 

Our SDK has dependencies that in turn are using doctrine as a dependency. One of dependencies should have instructions in the composer.json to not install this newer version of doctrine on php < 7.1. I don't know if the dependency we use doesn't have that in its composer.json, or if something failed when composer was installing on your machine. Either way, you ended up with PHP 7.0 and Doctrine/Annotations 1.5.0, and that's not going to work.

 

You can probably fix this either by upgrading PHP to 7.1, or downgrading doctrine/annotations to a 1.4.x version.

 

We could prevent this in the future by explictly declaring doctrine/annotations as a dependency in our own composer.json and locking to the preferred version, but we'd rather focus our efforts on getting rid of all dependencies.

View solution in original post

8 REPLIES 8

Hello @khurramshahzad

 

When you added the Authorize.Net PHP SDK to your project, did you run a composer update?

 

Richard

RichardH
Administrator Administrator
Administrator
Yes Sir, I absolutely did.

Could you run

composer show

in your project and post the output here?

Here is the output of

composer show

https://screencast.com/t/jSoHcSg9m

2017-08-02_0313
Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.

Thanks. And what's your PHP version?

I am running PHP 7.0.12

It appears that newer versions of Doctrine Annotations are using a void return type that wasn't introduced until PHP 7.1, thus causing that error.

 

Our SDK has dependencies that in turn are using doctrine as a dependency. One of dependencies should have instructions in the composer.json to not install this newer version of doctrine on php < 7.1. I don't know if the dependency we use doesn't have that in its composer.json, or if something failed when composer was installing on your machine. Either way, you ended up with PHP 7.0 and Doctrine/Annotations 1.5.0, and that's not going to work.

 

You can probably fix this either by upgrading PHP to 7.1, or downgrading doctrine/annotations to a 1.4.x version.

 

We could prevent this in the future by explictly declaring doctrine/annotations as a dependency in our own composer.json and locking to the preferred version, but we'd rather focus our efforts on getting rid of all dependencies.

Upgrading my PHP worked. 
Thank you so much Aaron.