gpt4 book ai didi

laravel-5 - Laravel 日志记录 "Class ' Arr' 在命令行代码 :1"中找不到

转载 作者:行者123 更新时间:2023-12-05 08:22:16 28 4
gpt4 key购买 nike

下面的错误是每分钟记录到 laravel 存储日志中的堆栈跟踪。

[2020-09-25 19:51:40] local.ERROR: Uncaught Error: Class 'Arr' not found in Command line code:1
Stack trace:
#0 {main}
thrown {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalErrorException(code: 1): Uncaught Error: Class 'Arr' not found in Command line code:1
Stack trace:
#0 {main}
thrown at Command line code:1)
[stacktrace]
#0 {main}
"}

我没有在我的 Controller 或 Blade 模板中的任何地方使用它。

感谢任何帮助。

最佳答案

对于收到此问题的任何人,这实际上是一个名为 laravel-extra-intellisense 的 VSCode Laravel 插件的问题。 .

这个问题实际上是插件的问题,因为它使用了 Laravel 5.8 及以上版本的功能,所以如果你的项目使用 Laravel 5.7 及以下版本,你可以这样做来清除错误。

在您的 config/app.php 中添加这一行

'Arr'         => Illuminate\Support\Arr::class, dlam config/app.php

添加该行后,您可能会收到这样的新错误

[2020-10-06 05:57:04] local.ERROR: Uncaught ReflectionException: Class App\Policies\ModelPolicy does not exist in Command line code:1
Stack trace:
#0 Command line code(1): ReflectionClass->__construct('App\\Policies\\Mo...')
#1 [internal function]: {closure}('App\\Policies\\Mo...', 'App\\Model')
#2 Command line code(1): array_map(Object(Closure), Array, Array)
#3 {main}
thrown {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalErrorException(code: 1): Uncaught ReflectionException: Class App\\Policies\\ModelPolicy does not exist in Command line code:1
Stack trace:
#0 Command line code(1): ReflectionClass->__construct('App\\\\Policies\\\\Mo...')
#1 [internal function]: {closure}('App\\\\Policies\\\\Mo...', 'App\\\\Model')
#2 Command line code(1): array_map(Object(Closure), Array, Array)
#3 {main}
thrown at Command line code:1)
[stacktrace]
#0 {main}
"}

您可以通过在 app\Providers\AuthServiceProvider.php 中注释这一行来解决这个问题

/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
// 'App\Model' => 'App\Policies\ModelPolicy', <-- comment this line
];

所有这些变化已经在最新的 Laravel(5.8 及以上版本)中

我认为发生这种情况是因为插件的记录器处理程序无法正常工作,所以这就是它登录到您的 Laravel 项目的原因。所以在修复之前,请执行上述操作或升级你的 laravel。

可以查看this issue in the plugin's github

关于laravel-5 - Laravel 日志记录 "Class ' Arr' 在命令行代码 :1"中找不到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64069920/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com