Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Terumi's avatar

Tinker reload?

Hello all,

I'm trying to create some App\User model methods and I'm using tinker to see the results, but If I change my code it doesn't get reflected in my current tinker session. I have to close tinker and reload it. So the process goes something like this:

php artisan tinker $user->find(2); $user->paths "some path"....

I change my code and then:

ctrl+d php artisan tinker $user->find(2); $user->paths "some other path"....

but this get quickly frustrating. Can I have tinker reload the code automatically?

0 likes
17 replies
mstnorris's avatar
Level 55

No, as far as I'm aware that isn't how it works unfortunately.

JarekTkaczyk's avatar

@Terumi No, you can't. Once the model has been used, it's can't be reloaded without quit/restart tinker shell.

deadlockgB's avatar

As the two before me said this is not working. For faster usage you could use some hotkey binding in your editor/IDE to open up a terminal for you just to save some time.

bashy's avatar

Elixir for tinker needed :P

7 likes
pilat's avatar

In iTerm2, you can open Preferences, then go to Keys, then add a new Key Mapping:

  1. Key Combination: I leave this to your own liking;
  2. Action: 'Send text with "vim" special characters"
  3. The text: exit\nphp artisan tinker\n.
3 likes
digitalredefined's avatar

I'm using iTerm 2 and what I found is just ctrl-c to cancel the tinker session. Then I can up arrow and get last command which would be to start the tinker session(enter). Up arrow again and you get the last command that you made in tinker.

phpguru's avatar

There's now a package (Tinx) that includes this capability:

The highlight feature of Tinx is the ability to update your Tinker session with the re() command

4 likes
szekeresa's avatar

Simple bash command:

while true; do php artisan tinker; done

CTRL+D = reload CTRL+C = exit

or

.profile file:

alias pat="php artisan tinker"

alias patt="while true; do php artisan tinker; done"

after type "pat" to normal tinker, and "patt" to continous tinker.

19 likes
Punksta's avatar

Yes you must reload tinker, but you can still its use-command recall to get your previously failing command.

debiprasad's avatar

This answer is provided by Larry, the AI Chatbot. This does not work, BTW.

Yes, you can reload Tinker without exiting by using the reload command. Here's how:

  1. Open Tinker by running the php artisan tinker command in your terminal.
  2. Once you're in Tinker, type reload and press enter.
  3. Tinker will reload and you can continue using it without having to exit and restart.

The reload command is useful when you've made changes to your Laravel application and want to reload the classes and functions in Tinker without having to exit and restart.

However, it's interesting how confident Larry is in his answer. This feature would be amazing if possible to implement.

1 like
isimmons's avatar

@debiprasad And now it shows up confidently in Google's generative AI search. Thanks for picking me up and then letting me down Google and Larry. AI is so gullible. It will believe anything it reads. :-)

2 likes
Snapey's avatar

@isimmons to try and balance the AI knowledge pool, I asked Lary here;

is it possible to reload code from within tinker?

Answer:

In Laravel, Tinker is a powerful REPL (Read-Eval-Print Loop) tool that allows you to interact with your Laravel application from the command line. However, Tinker does not automatically reload your code when changes are made. Once you start a Tinker session, it will not pick up changes made to your codebase until you exit and restart Tinker.

If you want to reload your code after making changes, you need to exit the Tinker session and start a new one. You can exit Tinker by typing exit or pressing Ctrl+D, and then you can start a new Tinker session by running php artisan tinker again.

Here's the process:

// Exit the current Tinker session exit

// Or press Ctrl+D

// Start a new Tinker session to reload the code php artisan tinker By restarting Tinker, you ensure that the latest code is loaded and that you can test the changes you've made.

2 likes
isimmons's avatar

@Snapey I installed tinkerwell today along with the plugin for phpstorm. It's pretty awesome.

tinkerwell phpstorm image

benfaerber's avatar

For anyone reading this, I created a mod to solve this problem. Check it out on GitHub: benfaerber/laravel-tinker-reload-mod

The best feature is it saves the variable context allowing for TinkerWell like interactive development!

Please or to participate in this conversation.