Can I run a command in Laravel Tinker within just one entry in the CLI?

I want to start using tinker to debug functions much faster. The issue is that for every change I need to stop and start tinker again.

I’m hoping I can use something like you have with mysql; you can start mysql and do your queries like that, but you can also run something like this
mysql -u root -e "select * from users"
which just works without starting up the mysql interface.

So I’m trying to find a way to do something like this

> tinker -e "User::find(1)->email"
"<a href="" class="__cf_email__" data-cfemail="a2cfdb8cd7d1c7d0e2c5cfc3cbce8cc1cdcf">[email protected]</a>"


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

you can use this php artisan tinker --execute='User::find(3)'
Or execute this php artisan tinker -h if you want to see more options

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x