将Laravel从5.7升级到5.8后,“ Class Blade.compiler不存在”

时间:2019-09-09 05:31:23

标签: laravel

我将Laravel项目从5.7版升级到5.8版。我修复了一些软件包,但是在成功升级之后,我检查了Laravel项目版本,出现了此错误:

  

blade.compiler类不存在

1 个答案:

答案 0 :(得分:0)

根据此问题:Move directive initialization to the boot method 您需要将 facades 别名从 register 扇区更改为 boot 初始化扇区...

/app/Providers/***Provider.php中查看文件

并将所有注册方法(带面)从register()更改为boot()

例如:

<?php

namespace App\Providers;

use Illuminate\Foundation\Support\Providers\AuthServiceProvider;
use Illuminate\Support\ServiceProvider;

class UserVehiclesProvider extends ServiceProvider {
    /**
     * Register services.
     *
     * @return void
     */

    public function boot() {  ### <= OK HERE
        $this->app->singleton('UserVehicles', UserVehicles::class);
    }

    public function register() {  ### <= BAD WITH FACADES
        $this->app->singleton('UserVehicles', UserVehicles::class);
    }
}

UPD:

或者您可以通过正确的方式进行操作(将 singleton 更改为 bind 方法)

<?php

namespace App\Providers;

use Illuminate\Foundation\Support\Providers\AuthServiceProvider;
use Illuminate\Support\ServiceProvider;

class UserVehiclesProvider extends ServiceProvider {
    /**
     * Register services.
     *
     * @return void
     */
    public function boot() {}

    public function register() {
        $this->app->bind('UserVehicles', function () { ### <= Use `bind` method
            return new \App\Services\UserVehicles();
        });
    }
}