Laravel’s Tinker quits immediately on PHP 7.3 & Mac

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, October 14, 2019

Follow me on Twitter as @mattiasgeniar

I had a weird issue with Laravel’s Tinker artisan command. Every time I would load it up and type a command, it would immediately quit.

$ php artisan tinker
Psy Shell v0.9.9 (PHP 7.3.8 — cli) by Justin Hileman
>>> Str::plural('url', 1);

$ 

It would just jump straight back my terminal prompt.

The fix appears to be to add a custom config that instructs PsySH – on which Tinker is built – to not use PHP’s pcntl extension for process control.

$ cat ~/.config/psysh/config.php
<?php
return [
  'usePcntl' => false,
];

That one did the tricky for me.

$ php artisan tinker
Psy Shell v0.9.9 (PHP 7.3.8 — cli) by Justin Hileman
>>> Str::plural('url', 1);
=> "url"
>>> Str::plural('url', 2);
=> "urls"

Hope this saves you some headaches!



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.