Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: #365

Closed
1 task done
richardhulbert opened this issue Aug 26, 2024 · 5 comments
Closed
1 task done

[Bug]: #365

richardhulbert opened this issue Aug 26, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@richardhulbert
Copy link

Short bug description

Tinker cannot find my classes so fails

Extended bug description

use \App\Models\Page;
Page::find(3);

results in

Fatal error: Uncaught Error: Class "App\Models\Page" not found in /in/aiERb:4
Stack trace:
#0 {main}
  thrown in /in/aiERb on line 4
<br/><i>Process exited with code <b title="Generic Error">255</b>.</i>

php is installed via brew
PHP 8.1.29 (cli)
@ /opt/homebrew/bin/php

Obviously this is something to do with my set up as others using Tinker with no probs. php artisan tinker works fine

Any suggestions?

Ta

Richard

Your project is not the problem

  • I tried using a fresh laravel install - I'm fairly certain it has nothing to do with my project.

How to reproduce?

use \App\Models\Page;
Page::find(3);

Expected behavior

 App\Models\Page {#6195
    id: 3,
    prime: 1,
    user_id: 1,
    title: "Home",
    slug: "/",
    template_id: 1,

Screenshots

No response

IDE & Version

PhpStorm 2024.1.5

PHP Version

8.1

OS and version

mac 13.6.9 (22G830)

Laravel Tinker plugin version

2.7.3

Interpreter type

Local

Laravel Version

9.52.16

Tinker version

2.7.3

Psysh version

v0.12.4

Additional Context

No response

@richardhulbert richardhulbert added the bug Something isn't working label Aug 26, 2024
@richardhulbert
Copy link
Author

@seeronline Clearly I am not going download and execute any code without explanation of what it does or assurance that it is not malicious ;-)

@Skyslycer
Copy link

Hi, same issue here. Similar simple artisan code. When I press run it just says that it can't find the file.
PHP Fatal error: Uncaught Error: Class "App\Models\Book" not found in /home/xxx/.config/JetBrains/PhpStorm2024.2/laravel-tinker/LaravelTinkerConsole.php:5

Please fix this. Thank you!

@Roboroads
Copy link
Owner

Roboroads commented Sep 9, 2024

You both are not executing through the tinker plugin, but running the PHP script as a simple PHP script. The tinker plugin adds the autoloader and laravel inits etc. to your code before executing, which a normal run does not.

Try the shortkey Ctrl+Shift+T or press the green tinker button in the gutter at line 1 of your tinker console.

@Roboroads
Copy link
Owner

I added a header for this issue in the FAQ in #250

@richardhulbert
Copy link
Author

richardhulbert commented Sep 9, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants
@Roboroads @richardhulbert @Skyslycer and others