Php 删除未使用的类后,Laravel 5.5上的依赖项注入不起作用

Php 删除未使用的类后,Laravel 5.5上的依赖项注入不起作用,php,laravel,inversion-of-control,autowired,Php,Laravel,Inversion Of Control,Autowired,这是完美的工作,但我删除了一些未使用的类,现在laravel的自动连接功能没有解决类型暗示的依赖关系 我已经在AppServiceProvider.php中声明了服务类的各种绑定,哪些依赖项应该通过自动连接来解决,但是没有 我留下了一个示例代码AppServiceProvider.php和一个类ProductoService.php 我错过了什么?提前谢谢 错误 类型错误:参数太少,无法运行 App\Services\ProductoService::\uu构造(),传入0 /上的home/ez

这是完美的工作,但我删除了一些未使用的类,现在laravel的自动连接功能没有解决类型暗示的依赖关系

我已经在
AppServiceProvider.php
中声明了服务类的各种绑定,哪些依赖项应该通过自动连接来解决,但是没有

我留下了一个示例代码
AppServiceProvider.php
和一个类
ProductoService.php

我错过了什么?提前谢谢

错误 类型错误:参数太少,无法运行 App\Services\ProductoService::\uu构造(),传入0 /上的home/eznb/Documentos/osiris/app/Providers/AppServiceProvider.php 第44行和第1行

AppServiceProvider.php ProductoService.php
请将您的AppServiceProvider.php更改为以下内容

 namespace App\Providers;
use App\Services\CajaService;
use App\Services\PrecioService;
use App\Services\ProductoService;
use App\Services\ServicioService;
use App\Services\TrabajoService;
use App\Services\TurnoService;
use Calendar;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //
        view()->composer('*', function ($view) {

            $event_list = [];

            $calendar_details = Calendar::addEvents($event_list);
            $view->with('calendar_details', $calendar_details);
        });
    }


    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bind(PrecioService::class, function ($app) {
            return new PrecioService();
        });
        $this->app->bind(ProductoService::class, function ($app) {
            return new ProductoService($app[PrecioService::class]); // Here i made the change as you ProductoService constructort has as its dependency
        });
        $this->app->bind(ServicioService::class, function ($app) {
            return new ServicioService();
        });
        $this->app->bind(CajaService::class, function ($app) {
            return new CajaService();
        });
        $this->app->bind(TrabajoService::class, function ($app) {
            return new TrabajoService();
        });
        $this->app->bind(TurnoService::class, function ($app) {
            return new TurnoService();
        });
    }
我已经使用$app[PrecioService::class]从服务容器中解析,因为您已经在这行$this->app->bind(PrecioService::class,function($app)中注册了它{ 返回新的PrecisionService(); });
希望这能解决你的疑问。如果您不清楚,可以在下面进行评论。如果需要,我将详细解释。

您尝试实例化
ProductoService
,但没有参数,这显然需要由服务容器解决。当你在服务容器中绑定一个类的时候不是这样的。好吧,我会测试它,但是直到昨天这是如何工作的?有某种缓存类解析,可能是解析了某种类型的暗示类?我没有足够的信息来回答这个问题。

namespace App\Services;

use App\Producto;
use App\Services\PrecioService;

class ProductoService
{
    protected $precio_service;

    public function __construct(PrecioService $precio_service)
    {
        $this->precio_service = $precio_service;
    }
.
.
.
some more core
.
.
.

 namespace App\Providers;
use App\Services\CajaService;
use App\Services\PrecioService;
use App\Services\ProductoService;
use App\Services\ServicioService;
use App\Services\TrabajoService;
use App\Services\TurnoService;
use Calendar;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //
        view()->composer('*', function ($view) {

            $event_list = [];

            $calendar_details = Calendar::addEvents($event_list);
            $view->with('calendar_details', $calendar_details);
        });
    }


    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bind(PrecioService::class, function ($app) {
            return new PrecioService();
        });
        $this->app->bind(ProductoService::class, function ($app) {
            return new ProductoService($app[PrecioService::class]); // Here i made the change as you ProductoService constructort has as its dependency
        });
        $this->app->bind(ServicioService::class, function ($app) {
            return new ServicioService();
        });
        $this->app->bind(CajaService::class, function ($app) {
            return new CajaService();
        });
        $this->app->bind(TrabajoService::class, function ($app) {
            return new TrabajoService();
        });
        $this->app->bind(TurnoService::class, function ($app) {
            return new TurnoService();
        });
    }