Laravel’s Tinker quits immediately on PHP 7.3 & Mac

Tired of the privacy invasion of the Chrome webbrowser? Worried about the risk of seeing ads everywhere? Give the Brave Browser a try. It supports all the same Chrome extensions, with none of the telemetry. It auto-blocks ads and helps support content creators like me.

Give the Brave browser a try »

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.