小编Leo*_*ori的帖子

BadMethodCallException 方法 Illuminate\Foundation\Application::share 不存在。Laravel 应用程序中出现错误

我已经在我的 laravel 项目上maatwebsite/excel使用命令行命令进行了安装composer require maatwebsite/excel。我已经按照指南设置了正确的别名和提供程序,但是当我运行时php artisan make:export ExportTimesheet --model=Timesheet,它会抛出错误:

BadMethodCallException 方法 Illuminate\Foundation\Application::share 不存在

这是生成错误的方法:

protected function bindClasses()
{
    // Bind the format identifier
    $this->app['excel.identifier'] = $this->app->share(function($app) {
        return new FormatIdentifier($app['files']);
    });
}
Run Code Online (Sandbox Code Playgroud)

我的提供商和别名是:

    'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
        Illuminate\Auth\AuthServiceProvider::class,
        Illuminate\Broadcasting\BroadcastServiceProvider::class,
        Illuminate\Bus\BusServiceProvider::class,
        Illuminate\Cache\CacheServiceProvider::class,
        Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
        Illuminate\Cookie\CookieServiceProvider::class,
        Illuminate\Database\DatabaseServiceProvider::class,
        Illuminate\Encryption\EncryptionServiceProvider::class,
        Illuminate\Filesystem\FilesystemServiceProvider::class,
        Illuminate\Foundation\Providers\FoundationServiceProvider::class,
        Illuminate\Hashing\HashServiceProvider::class,
        Illuminate\Mail\MailServiceProvider::class,
        Illuminate\Notifications\NotificationServiceProvider::class,
        Illuminate\Pagination\PaginationServiceProvider::class,
        Illuminate\Pipeline\PipelineServiceProvider::class,
        Illuminate\Queue\QueueServiceProvider::class,
        Illuminate\Redis\RedisServiceProvider::class,
        Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
        Illuminate\Session\SessionServiceProvider::class,
        Illuminate\Translation\TranslationServiceProvider::class,
        Illuminate\Validation\ValidationServiceProvider::class,
        Illuminate\View\ViewServiceProvider::class,
        Maatwebsite\Excel\ExcelServiceProvider::class,

        /*
         * Package Service Providers...
         */

        /*
         * …
Run Code Online (Sandbox Code Playgroud)

php laravel

6
推荐指数
2
解决办法
2万
查看次数

标签 统计

laravel ×1

php ×1