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

Softon\Indipay is not instantiable while building

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

Target [Softon\Indipay\Gateways\PaymentGatewayInterface] is not instantiable while building [\Softon\Indipay\Indipay].

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

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

谢谢。

在你的Laravelvendor\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