小编Gaz*_*ben的帖子

Laravel Excel [Illuminate \ Contracts \ Bus \ Dispatcher]无法实例化

我在php7.0上使用Laravel 5.2以及何时

我尝试使用Laravel excel(http://www.maatwebsite.nl/laravel-excel)。像这样:

public function export(){
    $users = User::with('roles')->get();

    $excel = Excel::create('beo_felhasznalo_export'. date('_Y-m-d_H-i-s'));

    //header
    $excel->appendRow(array(
        'felhasználónév', 'valódi név', 'e-mail', 'mobil', 'felhasználói szint'
    ));

    foreach($users as $user){
        $excel->appendRow(array(
            $user->username,
            $user->real_name,
            $user->email,
            $user->mobile_number,
            implode(',', $user->roles())
        ));
    }
    $excel->download('xls');
}
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

Illuminate\Contracts\Container\BindingResolutionException thrown with message "Target [Illuminate\Contracts\Bus\Dispatcher] is not instantiable."

Stacktrace:
#87 Illuminate\Contracts\Container\BindingResolutionException in D:\Projects\beo_site\vendor\laravel\framework\src\Illuminate\Container\Container.php:752
#86 Illuminate\Container\Container:build in D:\Projects\beo_site\vendor\laravel\framework\src\Illuminate\Container\Container.php:633
#85 Illuminate\Container\Container:make in D:\Projects\beo_site\vendor\laravel\framework\src\Illuminate\Foundation\Application.php:674
#84 Illuminate\Foundation\Application:make in D:\Projects\beo_site\vendor\laravel\framework\src\Illuminate\Container\Container.php:1178
#83 Illuminate\Container\Container:offsetGet in D:\Projects\beo_site\vendor\maatwebsite\excel\src\Maatwebsite\Excel\ExcelServiceProvider.php:123
#82 Maatwebsite\Excel\ExcelServiceProvider:Maatwebsite\Excel\{closure} in D:\Projects\beo_site\vendor\laravel\framework\src\Illuminate\Container\Container.php:289
#81 Illuminate\Container\Container:Illuminate\Container\{closure} in D:\Projects\beo_site\vendor\laravel\framework\src\Illuminate\Container\Container.php:735
#80 …
Run Code Online (Sandbox Code Playgroud)

laravel laravel-excel laravel-5.2

1
推荐指数
1
解决办法
3108
查看次数

标签 统计

laravel ×1

laravel-5.2 ×1

laravel-excel ×1