mac php8.0升级8.1后项目报错

1. 运行环境

本地环境。线上还是php8.0项目没有问题,本地安装不了php8.0了,homebrew禁用php8.0所以升级8.1

. 当前使用的 php 版本?

PHP 版本:8.1

. 当前系统

Mac系统

2. 问题描述?

项目报错 执行php artisan –version也报错
PHP Deprecated: Return type of Illuminate\Container\Container::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Applications/phpstudy/WWW/new_mas/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1231

Deprecated: Return type of Illuminate\Container\Container::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Applications/phpstudy/WWW/new_mas/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1231

PHP Deprecated: Return type of Illuminate\Container\Container::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Applications/phpstudy/WWW/new_mas/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1242

Deprecated: Return type of Illuminate\Container\Container::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Applications/phpstudy/WWW/new_mas/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1242

PHP Deprecated: Return type of Illuminate\Container\Container::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Applications/phpstudy/WWW/new_mas/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1254

Deprecated: Return type of Illuminate\Container\Container::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Applications/phpstudy/WWW/new_mas/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1254

PHP Deprecated: Return type of Illuminate\Container\Container::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 /Applications/phpstudy/WWW/new_mas/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1267

Deprecated: Return type of Illuminate\Container\Container::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 /Applications/phpstudy/WWW/new_mas/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1267

PHP Deprecated: Return type of Illuminate\Config\Repository::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Applications/phpstudy/WWW/new_mas/vendor/laravel/framework/src/Illuminate/Config/Repository.php on line 141

Deprecated: Return type of Illuminate\Config\Repository::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Applications/phpstudy/WWW/new_mas/vendor/laravel/framework/src/Illuminate/Config/Repository.php on line 141

PHP Deprecated: Return type of Illuminate\Config\Repository::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Applications/phpstudy/WWW/new_mas/vendor/laravel/framework/src/Illuminate/Config/Repository.php on line 152

Deprecated: Return type of Illuminate\Config\Repository::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Applications/phpstudy/WWW/new_mas/vendor/laravel/framework/src/Illuminate/Config/Repository.php on line 152

PHP Deprecated: Return type of Illuminate\Config\Repository::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Applications/phpstudy/WWW/new_mas/vendor/laravel/framework/src/Illuminate/Config/Repository.php on line 164

Deprecated: Return type of Illuminate\Config\Repository::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Applications/phpstudy/WWW/new_mas/vendor/laravel/framework/src/Illuminate/Config/Repository.php on line 164

PHP 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 /Applications/phpstudy/WWW/new_mas/vendor/laravel/framework/src/Illuminate/Config/Repository.php on line 175

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 /Applications/phpstudy/WWW/new_mas/vendor/laravel/framework/src/Illuminate/Config/Repository.php on line 175

PHP Fatal error: During inheritance of ArrayAccess: Uncaught ErrorException: Return type of Illuminate\Support\Collection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Applications/phpstudy/WWW/new_mas/vendor/laravel/framework/src/Illuminate/Support/Collection.php:1277

. 大佬们给看看啊 怎么解决

《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
最佳答案

感谢各位大佬帮助,问题已顺利解决。最终将框架升级到了8以上版本,一切运行正常。(通过清除vendor文件夹并调整composer.json文件中的依赖版本,实现了顺利升级)

1个月前 评论
讨论数量: 19
sanders

框架用的版本是啥?要不要考虑也升级一下?一般这种问题就是要将环境版本分开进行处理, Docker 在这方面是比较理想的解决方案。

1个月前 评论
zhangshsh (楼主) 1个月前
sanders (作者) 1个月前
zhangshsh (楼主) 1个月前
sanders (作者) 1个月前

vendor/laravel/framework/src/Illuminate/Support/Collection.php

这个文件下面的方法加一个返回类型 bool

{
    return isset($this->items[$key]);
}```
1个月前 评论
zhangshsh (楼主) 1个月前

降低php版本,要么把框架版本升级上去

1个月前 评论
pan_zoe 1个月前
zhangshsh (楼主) 1个月前
deatil (作者) 1个月前
zhangshsh (楼主) 1个月前
pan_zoe 1个月前
CodingHePing

这个是larvel和php 的版本不匹配吧?

1个月前 评论

larvel 和 php 的版本不匹配
在github上找个dnmp包一步到位 github.com/search?q=dnmp&type=...

1个月前 评论
Buffett-Cai

你用的框架已经不维护了,升级也没用

1个月前 评论

你的 laravel 版本太低了。官方已经明明白白的说了,v6只支持到 8.0。

你这最起码得升级到 Laravel v8。

file

1个月前 评论

感谢各位大佬帮助,问题已顺利解决。最终将框架升级到了8以上版本,一切运行正常。(通过清除vendor文件夹并调整composer.json文件中的依赖版本,实现了顺利升级)

1个月前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!