【问题标题】:"Class blade.compiler does not exist" after upgrading Laravel from 5.7 to 5.8Laravel 从 5.7 升级到 5.8 后出现“classblade.compiler 不存在”
【发布时间】:2019-09-09 05:31:23
【问题描述】:

我将 Laravel 项目从 5.7 版升级到 5.8 版。我修复了一些包,但是在成功升级后我检查了我的 Laravel 项目版本,我收到了这个错误:

classblade.compiler 不存在

【问题讨论】:

标签: laravel


【解决方案1】:

根据这个问题: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();
        });
    }
}

【讨论】:

    猜你喜欢
    • 2020-02-07
    • 2019-12-19
    • 2019-12-05
    • 1970-01-01
    • 2020-12-07
    • 2019-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多