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

[NOTICE] FAQ, read before posting! #250

Closed
Roboroads opened this issue Apr 17, 2023 · 2 comments
Closed

[NOTICE] FAQ, read before posting! #250

Roboroads opened this issue Apr 17, 2023 · 2 comments
Labels

Comments

@Roboroads
Copy link
Owner

Roboroads commented Apr 17, 2023

Hey! Before you post a bug, please first check your interpreter settings. Most likely, your interpreter or path mappings are incorrect and this has nothing to do with the plugin.

Connection to database failed But site/tinker CLI works fine

99.9% sure you are using a local interpreter whilst your application is running in docker or a VM. In that case, the PHP tinker is using can, indeed, not reach your DB.

Go to your settings, and under PHP check your interpreter. Make sure you are using the same PHP executable as your CLI does. E.g., if you use sail, make sure you use the docker compose interpreter on your PHP container (laravel.test). If you use SSH (homestead/vagrant/vm/VPS) use the vagrant or SSH option.

If you do not have these options, make sure you have the "remote interpreters" plugin installed. It's bundled in PHPStorm, but not in IntelliJ

Mounted volumes

If you use a remote/docker interpreter, please make sure that your project is shared with the interpreter. The interpreter you are using also needs to have access to all the files of your project. Also make sure that the working directory of the interpreter is setup in the forlder where your project is located on the interpreter.

If you're using an interpreter via SSH, make sure your project is fully uploaded to the interpreter and stays in sync.

Path mappings

Then, if your project is mounted, please also make sure that the right directory in the interpreter is also mapped to the absolute path on the host to the absolute path on the interpreter. That way, Tinker knows where to find your project.

Where to find this

  • In PHPStorm, go to Settings -> PHP.
  • In other JB IDE's, PHP is found in settings under "Languages & Frameworks".

Tinker Settings

If you can't change the working directory or your vendor/laravel folder is located somewhere else, tou can force override the folder (of the interpreter) in the project settings of the tinker plugin. You can find those under Tools > Laravel Tinker > Project settings.

3v4l.org

image
In a later update PHPStorm added running code in 3v4l.org - this is the play button you find above your tinker consoles (red arrow). Note that this play button does not run your code with Tinker. Use the green tinker icon in the gutter (green arrow), or any of the other 5 ways to run the tinker console (like the hotkey).

Still having problems?

I doubt I can help you. These errors are 99,9% related to the interpreter settings - which Tinker uses to execute your PHP code.

@dennyweiss
Copy link

@Roboroads, as pointed out in #249, there is one additional case you could implement.

`$app = require_once DIR . $relativeCustomProjectDirectory . '/bootstrap/app.php';

But for this, you require an option that denotes that path of the plugin path input has to be treated as relative.

@Roboroads
Copy link
Owner Author

@dennyweiss Added it to the list :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants