我试图让PHP Hello World example工作。我从authorize.net网站下载了代码,并使用Composer和给定的composer.json
文件。authorize.net PHP Hello World bug
当我运行命令作曲家更新,我得到一个警告消息:
Package goetas/xsd2php is abandoned, you should avoid using it. Use goetas-webservices/xsd2php instead.
Package goetas/xsd-reader is abandoned, you should avoid using it. Use goetas-webservices/xsd-reader instead.
我试图不顾警告的运行充电信贷card.php程序,但我得到这个错误:
Fatal error: Class 'Goetas\Xsd\XsdToPhp\Jms\Handler\BaseTypesHandler' not found in /var/www/public/newsite/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php on line 82
我想我的手在纠正composer.json文件,以摆脱错误的,但我只挖自己更深的一个洞。
这里是composer.json文件供参考。
{
"require":
{ "php": ">=5.2.0",
"ext-curl": "*",
"authorizenet/authorizenet": "1.8.8",
"jms/serializer": "xsd2php-dev as 0.18.0"},
"require-dev":
{
"goetas/xsd2php": "2.*@dev",
"goetas/xsd-reader": "2.*@dev"},
"repositories":
[{
"type": "vcs",
"url": "https://github.com/goetas/serializer.git"
}]}
而这里的我运行PHP程序...
<?php
require 'vendor/autoload.php';
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;
define("AUTHORIZENET_LOG_FILE","phplog");
// Common setup for API credentials
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName("123456789");
$merchantAuthentication->setTransactionKey("abcdefghijklmnop");
$refId = 'ref' . time();
// Create the payment data for a credit card
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber("4111111111111111");
$creditCard->setExpirationDate("2038-12");
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setCreditCard($creditCard);
// Create a transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("authCaptureTransaction");
$transactionRequestType->setAmount(151.51);
$transactionRequestType->setPayment($paymentOne);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$request->setTransactionRequest($transactionRequestType);
// if I comment out the line below, no error occurs
$controller = new AnetController\CreateTransactionController($request);
// $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
echo "<p>Hello there 10. The reference id is " . $refId . "</p>";
?>
以下是运行作曲家输出控制台安装
Loading composer repositories with package information
Reading composer.json of jms/serializer (0.16.0)
Reading composer.json of jms/serializer (0.15.0)
Reading composer.json of jms/serializer (0.14.0)
Reading composer.json of jms/serializer (0.13.0)
Reading composer.json of jms/serializer (0.12.0)
Reading composer.json of jms/serializer (0.11.0)
Reading composer.json of jms/serializer (event-sdispatcher)
Reading composer.json of jms/serializer (graph-refactor)
Reading composer.json of jms/serializer (master)
Reading composer.json of jms/serializer (ok-for-lignano)
Reading composer.json of jms/serializer (patch-1)
Reading composer.json of jms/serializer (psr4)
Reading composer.json of jms/serializer (remove-hndl)
Reading composer.json of jms/serializer (serializer-master)
Reading composer.json of jms/serializer (xsd2php)
Updating dependencies (including require-dev)
- Installing doctrine/lexer (v1.0.1)
Loading from cache
- Installing doctrine/annotations (v1.3.0)
Loading from cache
- Installing phpoption/phpoption (1.5.0)
Loading from cache
- Installing phpcollection/phpcollection (0.5.0)
Loading from cache
- Installing jms/parser-lib (1.0.0)
Loading from cache
- Installing jms/metadata (1.5.1)
Loading from cache
- Installing jms/serializer (dev-xsd2php f339d96)
Cloning f339d96f7e359e2837ed8b752348cc84823a9966
- Installing goetas-webservices/xsd-reader (v0.1.2)
Loading from cache
- Installing zendframework/zend-eventmanager (3.0.1)
Loading from cache
- Installing zendframework/zend-code (2.6.3)
Loading from cache
- Installing doctrine/inflector (v1.1.0)
Loading from cache
- Installing symfony/yaml (v3.1.6)
Loading from cache
- Installing psr/log (1.0.2)
Loading from cache
- Installing symfony/debug (v3.1.6)
Loading from cache
- Installing symfony/polyfill-mbstring (v1.2.0)
Loading from cache
- Installing symfony/console (v3.1.6)
Loading from cache
- Installing goetas/xsd2php (dev-master 7e1ab0a)
Cloning 7e1ab0a2d007991b0c6d326e9f67ec90c020b5e5
- Installing goetas/xsd-reader (dev-master c5bcc02)
Cloning c5bcc02d1a07f26533991e7b0d6c51a98d78c02c
- Installing authorizenet/authorizenet (1.8.8)
Loading from cache
zendframework/zend-eventmanager suggests installing container-interop/container-interop (^1.1.0, to use the lazy listeners feature)
zendframework/zend-eventmanager suggests installing zendframework/zend-stdlib (^2.7.3 || ^3.0, to use the FilterChain feature)
zendframework/zend-code suggests installing zendframework/zend-stdlib (Zend\Stdlib component)
symfony/console suggests installing symfony/event-dispatcher()
symfony/console suggests installing symfony/process()
authorizenet/authorizenet suggests installing phpdocumentor/phpdocumentor (For generating API documentation)
Package goetas/xsd2php is abandoned, you should avoid using it. Use goetas-webservices/xsd2php instead.
Package goetas/xsd-reader is abandoned, you should avoid using it. Use goetas-webservices/xsd-reader instead.
Writing lock file
Generating autoload files
的'..'是,一般来说,这是一个有效的构造 - 它在目录树的一个层次上。在你的情况下,解析为'/ var/www/public/newsite/vendor/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/MerchantAuthenticationType.php。你会在服务器上检查你的项目,看看那个路径不存在的地方,让我们知道吗? – halfer
这可能是你的'composer update'没有正确运行。在项目文件夹中,使用'rm -rf vendor'销毁供应商文件夹并再次运行Composer命令,并将整个输出粘贴到问题中。 – halfer
@halfer谢谢你,你在这里正确的轨道上。我没有注意到,这个路径在授权网络中崩溃,这个授权网络不在供应商之下,无处可寻。正如你所说,这可能是一个作曲家的问题。我实际上尝试了两个不同的composer.json文件,今天我看到了第三个看起来更简单的文件。我会尝试一个,让你知道它是如何工作的。 – Chuck