Softon \ Indipay在构建时不可实例化

时间:2017-03-03 22:09:57

标签: php laravel payment-gateway service-provider

当我尝试在Laravel 5.4 *上实例化Soften\Indipay时收到此消息 github

  

构建[\ Softon \ Indipay \ Indipay]时,目标[Softon \ Indipay \ Gateways \ PaymentGatewayInterface]无法实例化。

我在app/config.php注册了它,但它不起作用,我该如何解决?

'providers' => [
    ....
    Softon\Indipay\IndipayServiceProvider::class,
    ....
];

谢谢。

1 个答案:

答案 0 :(得分:0)

在你的Laravel中vendor\softon\indipay\src\IndipayServiceProvider.php 修改register函数,以便绑定中没有前导斜杠。

$this->app->bind('indipay', '\Softon\Indipay\Indipay');
$this->app->bind('\Softon\Indipay\Gateways\PaymentGatewayInterface','\Softon\Indipay\Gateways\\'.$gateway.'Gateway');

现在应该看起来像

$this->app->bind('indipay', 'Softon\Indipay\Indipay');
$this->app->bind('Softon\Indipay\Gateways\PaymentGatewayInterface','Softon\Indipay\Gateways\\'.$gateway.'Gateway');

另外,不要忘记将Indipay别名添加为

'Indipay' => 'Softon\Indipay\Facades\Indipay',

config/app.php