Reputation: 21
i want to make export excel using composer require maatwebsite/excel
this is composer.json code { "name": "laravel/laravel", "type": "project", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "require": { "php": "^8.0.2", "barryvdh/laravel-dompdf": "^2.0", "guzzlehttp/guzzle": "^7.2", "laravel/framework": "^9.19", "laravel/sanctum": "^3.0", "laravel/tinker": "^2.7", "laravel/ui": "^4.0", "maatwebsite/excel": "*" }, "require-dev": { "fakerphp/faker": "^1.9.1", "laravel/pint": "^1.0", "laravel/sail": "^1.0.1", "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^6.1", "phpunit/phpunit": "^9.5.10", "spatie/laravel-ignition": "^1.0" }, "autoload": { "psr-4": { "App\": "app/", "Database\Factories\": "database/factories/", "Database\Seeders\": "database/seeders/" } }, "autoload-dev": { "psr-4": { "Tests\": "tests/" } }, "scripts": { "post-autoload-dump": [ "Illuminate\Foundation\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi" ], "post-update-cmd": [ "@php artisan vendor:publish --tag=laravel-assets --ansi --force" ], "post-root-package-install": [ "@php -r "file_exists('.env') || copy('.env.example', '.env');"" ], "post-create-project-cmd": [ "@php artisan key:generate --ansi" ] }, "extra": { "laravel": { "dont-discover": [] } }, "config": { "optimize-autoloader": true, "preferred-install": "dist", "sort-packages": true, "allow-plugins": { "pestphp/pest-plugin": true } }, "minimum-stability": "dev", "prefer-stable": true }
when i write
php artisan vendor:publish –provider=”Maatwebsite\Excel\ExcelServiceProvider” –tag=config
the error appears as follows:
Call to undefined method Illuminate\Foundation\Application::share()
at vendor/maatwebsite/excel/src/Maatwebsite/Excel/ExcelServiceProvider.php:159
155▕ */
156▕ protected function bindClasses()
157▕ {
158▕ // Bind the format identifier
➜ 159▕ $this->app['excel.identifier'] = $this->app->share(function($app) {
160▕ return new FormatIdentifier($app['files']);
161▕ });
162▕ }
163▕
+8 vendor frames
9 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
I have followed these tips, but still confused about the share() method in the comments all or not? Laravel - Call to undefined method Illuminate\Foundation\Application::share()
Upvotes: 1
Views: 2941
Reputation: 349
when this error appeared to me
i found out that i installed old version of Laravel/Excel
even when i try to run composer dump-autoload
it also showed me the same error
the solution that worked to me is composer update
it upgraded the laravel/Excel
there is also some solution here that may help you
Upvotes: 1