错误视图:
目标[App \ Services \ OrderServiceInterface]无法实例化。
提供者:
class OrderServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register services.
*
* @return void
*/
public function register()
{
$this->app->bind('App\Services\OrderServiceInterface', 'App\Services\OrderService');
}
}
OrderServiceInterface 是接口:
<?php
namespace App\Services;
interface OrderServiceInterface
{
public function doSomethingUseful();
}
OrderService 是一个特定的类:
<?php
namespace App\Services;
class OrderService implements OrderServiceInterface
{
public function doSomethingUseful()
{
return 'Output from DemoOne';
}
}
用法:
public function accept(Request $request, OrderServiceInterface $orderService) {}
答案 0 :(得分:2)
如果您的服务提供商似乎尚未注册,请尝试运行:
composer dump-autoload
php artisan cache:clear
感谢@adam
php artisan config:clear