Laravel-Excel: [Bug]: Compatible error with Psr\SimpleCache\CacheInterface::get
Is the bug applicable and reproducable to the latest version of the package and hasn’t it been reported before?
- Yes, it’s still reproducable
What version of Laravel Excel are you using?
^3.1
What version of Laravel are you using?
9.31
What version of PHP are you using?
8.1
Describe your issue
Running composer update returns the following error
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
PHP Fatal error: Declaration of Maatwebsite\Excel\Cache\MemoryCache::get($key, $default = null) must be compatible with Psr\SimpleCache\CacheInterface::get(string $key, mixed $default = null): mixed in /var/www/html/vendor/maatwebsite/excel/src/Cache/MemoryCache.php on line 62
Symfony\Component\ErrorHandler\Error\FatalError
Declaration of Maatwebsite\Excel\Cache\MemoryCache::get($key, $default = null) must be compatible with Psr\SimpleCache\CacheInterface::get(string $key, mixed $default = null): mixed
at vendor/maatwebsite/excel/src/Cache/MemoryCache.php:62
58▕
59▕ /**
60▕ * {@inheritdoc}
61▕ */
➜ 62▕ public function get($key, $default = null)
63▕ {
64▕ if ($this->has($key)) {
65▕ return $this->cache[$key];
66▕ }
How can the issue be reproduced?
composer update
What should be the expected behaviour?
update function
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 21
- Comments: 20 (5 by maintainers)
Commits related to this issue
- Fix psr/simple-cache to version 2 in relation to phpspreadsheet issue https://github.com/SpartnerNL/Laravel-Excel/issues/3731 — committed to OHFLesvos/ohf-community by mrcage 2 years ago
- fixed `psr-cache` <> `laravel-excel` conflict https://github.com/SpartnerNL/Laravel-Excel/issues/3731 — committed to akaunting/akaunting by denisdulici 2 years ago
any update on this issue? its breaking a lot of projects @SpartnerNL
can confirm this
A fix has been released
Just run
composer require psr/simple-cache:^2.0 maatwebsite/excel
in your project, that fixes this issue as far as I know.Also per installation docs: https://docs.laravel-excel.com/3.1/getting-started/installation.html
The PR that solves the problem: https://github.com/SpartnerNL/Laravel-Excel/pull/3733
Downgraded psr/simple-cache to ^2.0
this should be added to this package composer.json if that’s the case. will make a PR
composer require psr/simple-cache:^2.0 maatwebsite/excel
i get what u mean. when u do composer update, composer will upgrade psr-simple cache to 3.0 and keep this package at 3.1.40
So you will have to update your composer.json to
“maatwebsite/excel” : “^3.1.41”