2

The error below is the stack trace which is being logged to the laravel storage log every minute.

[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}
"} 

I haven't used this anywhere in my controllers or blade templates.

Any help is appreciated.

Sean Treanor
  • 51
  • 2
  • 7
  • Does this answer your question? [Laravel 5.8 - Class 'Arr' not found](https://stackoverflow.com/questions/55881379/laravel-5-8-class-arr-not-found) – ceejayoz Sep 25 '20 at 18:59
  • I haven’t implemented the class in my blade templates (or anywhere) like shown in that example. – Sean Treanor Sep 25 '20 at 20:17
  • Something is; the fix above should resolve it. – ceejayoz Sep 25 '20 at 22:08
  • it just complains about the policy class not being there when I add those. I haven't changes anything for this to start happening which is strange. – Sean Treanor Sep 26 '20 at 10:31
  • this happens to me too at around 5 days ago too. This is weird. – Ashraf Kamarudin Oct 01 '20 at 03:30
  • @AshrafKamarudin I think I have narrowed this down to being the Laravel plugins that are available in some of the IDE's (mine being Visual Studio Code). If you are using an older version of Laravel, try to disable these plugins and this issue should stop. I started digging into when I realised the errors were still being logged regardless of whether my server was running. – Sean Treanor Oct 02 '20 at 09:38

2 Answers2

13

For anyone receiving this issue, This is actually an issue with a VSCode Laravel's Plugin called laravel-extra-intellisense.

The issue is actually from the plugin's issue as it uses functionality from Laravel 5.8 and above, so if your project uses Laravel's 5.7 and below you can do this to clear the error.

add this line in your config/app.php

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

and after adding the line, you may received a new error like so

[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}
"} 

You can solve this one by commenting this line in app\Providers\AuthServiceProvider.php

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

All of these changes is already in the lastest Laravel (version 5.8 and above)

I think this happens because the plugin's logger handler isn't working so that is why it logs in your laravel's project. So until it is fixed, please do the above or upgrade your laravel.

You can check this issue in the plugin's github

Ashraf Kamarudin
  • 522
  • 6
  • 24
  • This issue has been driving me nuts, specifically `App\Policies\ModelPolicy does not exist in Command line code:1`. I still had to comment out the 'App\Model' policy, even though I'm running 5.8. – Bennett Oct 13 '20 at 19:13
  • 2
    @Bennett if you upgrade your Laravel from 5.7 and below to 5.8 and up, you still need to comment on the line as the upgrade did not comment on it for you. An only fresh install will have it commented right away. – Ashraf Kamarudin Oct 14 '20 at 06:53
  • This answer is a lifesaver. Thanks! <3 – BakaDesu Nov 10 '20 at 08:14
0

I appreciate the help but I solved this by uninstalling and reinstalling valet.

Makes no sense but thankfully the errors are gone.

Sean

Sean Treanor
  • 51
  • 2
  • 7