question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Uncaught Error Class App\Models\User not found

See original GitHub issue

Short bug description

When I run tinker with a simple script it displays an error that a model does not exist

Extended bug description

The script works fine in command line php artisan tinker.

How to reproduce?

  1. In PHPStorm 2022.3, run tinker, add simple script:
<?php
//Tinker away!
use App\Models\User;
echo User::all();
  1. Right-click, click "Run ‘LaravelTinkerConsole’… " in the context menu.
  2. Notice this error appears in the console box:
C:\xampp71\php818\php.exe C:\Users\chris\AppData\Roaming\JetBrains\PhpStorm2022.3\laravel-tinker\LaravelTinkerConsole.php
PHP Fatal error:  Uncaught Error: Class "App\Models\User" not found in C:\Users\chris\AppData\Roaming\JetBrains\PhpStorm2021.2\laravel-tinker\LaravelTinkerConsole.php:6
Stack trace:
#0 {main}
  thrown in C:\Users\chris\AppData\Roaming\JetBrains\PhpStorm2022.3\laravel-tinker\LaravelTinkerConsole.php on line 6

Process finished with exit code 255

Expected behavior

I’d expect to see the same as what I see when running Tinker via the CLI.

Screenshots

Screenshot Link

Screenshot-2022-12-14-PHPStorm_Tinker_Console

IDE & Version

PhpStorm 2022.3

PHP Version

8.1.8

OS and version

Windows 11

Laravel Tinker plugin version

2.5.0

Interpreter type

{“label”=>“Local”}

Laravel Version

9.37.0

Tinker version

v2.7.2

Psysh version

v0.11.8

Additional Context

I just installed the plugin and was testing it.

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Roboroadscommented, Dec 14, 2022

So, first, I see that the script is not running through my plugin.

Right-click, click "Run ‘LaravelTinkerConsole’… " in the context menu.

This doesn’t work - PHPStorm runs the file with his own interpreter. Please use a tinker method for running:

  • Hotkey <key>ctrl+shift+T</key> for Tinker smart action.
  • Tools > Laravel Tinker > Run tinker console.
    • “Smart action: Run tinker console” - does the same
  • Press the Play-button on the line with <?php
    image

The bug here is that the context menu item should not be there 😃

0reactions
Roboroadscommented, Dec 19, 2022

I changed the play icon for a green tinker icon, yes. I trhough that was more fun

Read more comments on GitHub >

github_iconTop Results From Across the Web

Class '\App\User' not found in Laravel when changing the ...
Go to config/auth.php and change App\User:class to App\Models\User::class. 'providers' => [ 'users' => [ 'driver' => 'eloquent', ...
Read more >
Error Class App User not found in Laravel when changing the ...
I am having this error when moving User.php to Models/User.php local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Fatal ...
Read more >
Fatal error: Class 'App\User' not found. (Custom folder for ...
Hello I keep all models in the App\Models. So there is an error "FatalThrowableError in InstallController.php line 53: Fatal error: Class ...
Read more >
Class 'App\Models\User' not found - Laracasts
I am trying to create new use. but this error keeps poping up tho i have my user model at place. use App\Http\Controllers\Controller; ......
Read more >
Class 'App\Http\Controllers\Response' not found - Code Grepper
“Error Class 'App\Http\Controllers\Controller' not found” Code Answer's. Grepper Logo Small. Search. 75. Loose MatchExact Match. 9 Code Answers.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found