【问题标题】:Softon\Indipay is not instantiable while buildingSofton\Indipay 在构建时不可实例化
【发布时间】:2017-07-24 04:17:08
【问题描述】:
当我尝试在 Laravel 5.4 上实例化 Soften\Indipay 时收到此消息*
github
在构建 [\Softon\Indipay\Indipay] 时,目标 [Softon\Indipay\Gateways\PaymentGatewayInterface] 不可实例化。
我在app/config.php注册了它,但它不起作用,我该如何解决它?
'providers' => [
....
Softon\Indipay\IndipayServiceProvider::class,
....
];
谢谢。
【问题讨论】:
标签:
php
laravel
payment-gateway
service-provider
【解决方案1】:
在你的 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