mercredi 12 décembre 2018

Error class initialization in the provider?

Error view:

Target [App\Services\OrderServiceInterface] is not instantiable.

Provider:

public function register()
    {
        $this->app->bind('App\Services\OrderServiceInterface', OrderService::class);
    }

Where OrderServiceInterface is interface:

<?php

namespace App\Services; 

interface OrderServiceInterface
{

    public function doSomethingUseful();

}

And OrderService is a specific class:

<?php

namespace App\Services;

class OrderService implements OrderServiceInterface
{
    public function doSomethingUseful()
    {
        return 'Output from DemoOne';
    }
}

Usage:

public function accept(Request $request, OrderServiceInterface $orderService) {}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire