menu

Questions & Answers

Laravel 7 Legacy Projects - Deprecated: Return type of Illuminate\Config\Repository

I copied fresh new laravel project from my repository and was having trouble with ArrayAccess functions. As this will be depricated with version PHP 8.0 and PHP 8.1.

Does anyone have a quick guide to fix this for legacy projects?

Deprecated: Return type of Illuminate\Config\Repository::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in
Comments:
2023-01-20 23:30:11
Laravel 7 is end of life so if there's incompatibilities with PHP 8.1 then I don't expect it to be fixed
Answers(1) :

Here the fix i followed and hopefully you can follow the same steps.

This guide only works on php@7.4 Please use only if u are on the latest version of php@7.4

composer global update

composer du

brew unlink php@7.4
 
brew link php@7.4 --force 

valet use php@7.4 --force

After restarting nginx it worked.