mercredi 26 septembre 2018

laravel - DI, Class not found

I'm have created service for my application:
ProductsShelfService

<?php
declare(strict_types=1);
namespace App\Modules\ProductList\Services;

class ProductsShelfService
{
    public function sample()
    {
        return 'I am ProductsShelfService class!';
    }
}

and now I want to pass it to controller via DI:
ProductListController

<?php
declare(strict_types=1);
namespace App\Http\Controllers\Website\Pages;

use App\Http\Controllers\Controller;
use App\Modules\ProductList\Services\ProductsShelfService;

class ProductListController extends Controller
{
    /**
     * @var ProductsShelfService
     */
    protected $shelfService;

    public function __construct(ProductsShelfService $shelfService)
    {
        $this->shelfService = $shelfService;
    }

    public function index()
    {
        echo $this->shelfService->sample();
    }
}

but I getting error:

ReflectionException
Class App\Modules\ProductList\Services\ProductsShelfService does not exist

Why? I need to do sth more?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2OROzJ8
via IFTTT

Aucun commentaire:

Enregistrer un commentaire