VSCode 中的 Laravel 9 + PHP 8.0.8 显示语法错误,意外的 '->' (T_OBJECT_OPERATOR)

2024-05-06

为什么我在 PHP 8.0.8 上新创建的 laravel 9 项目在 Visual Studio Code 中显示错误?

VSCode 将其显示为错误:

return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());

如果您在预装了 PHP 的 macOS 上使用 MAMP,例如 macOS Mojave 上的 PHP 7.1.33,则在 Visual Studio Code 设置中进行更改,PHP > 验证:可执行路径 - 在 settings.json 中编辑:

"php.validate.executablePath": ""
or
"php.validate.executablePath": "/usr/bin/php"
to 
"php.validate.executablePath": "/Applications/MAMP/bin/php/php8.0.8/bin/php"

https://code.visualstudio.com/docs/languages/php https://code.visualstudio.com/docs/languages/php

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

VSCode 中的 Laravel 9 + PHP 8.0.8 显示语法错误,意外的 '->' (T_OBJECT_OPERATOR) 的相关文章

随机推荐