Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Artisan Tinker crashing from any command

I haven't had this problem before, but my php artisan tinker crashes from issuing any command - and leaves no logs whatsoever on what is causing the crash.

project4 $ php artisan tinker
Psy Shell v0.9.9 (PHP 7.3.0 — cli) by Justin Hileman
>>> use \App\Jobs\testJob;
project4 $

or even the simplest command:

project4 $ php artisan tinker
Psy Shell v0.9.9 (PHP 7.3.0 — cli) by Justin Hileman
>>> print("Hello World!");
project4 $

I almost wonder if it isn't connecting to PHP correctly, but I can't find any logs anywhere. Laravel has no trace of the commands. I ran brew update, but no difference. For the record, all of my projects are affected. I can't tinker on any of my projects. Help!

I did recently upgrade to PHP 7.3.0, which is working fine in every other area. Hmm...

like image 735
G.S. Avatar asked Dec 14 '18 03:12

G.S.


People also ask

What does php artisan Tinker do?

The php artisan is a command-line interface that is available with a Laravel. Tinker is a command tool that works with a php artisan. A tinker plays around the database means that it allows you to create the objects, insert the data, etc. The above screen shows that the tinker environment has been created.

How do you stop the artisan tinker in php?

You can exit tinker mode with either ctrl+c (as you mentioned) or typing exit; and hitting enter.

What is meant by php artisan?

Artisan is the name of the command-line interface included with Laravel. It provides a number of helpful commands for your use while developing your application. It is driven by the powerful Symfony Console component.


2 Answers

If you don't have the pcntl extension installed, try creating a config file at ~/.config/psysh/config.php if not already there:

<?php
return [
  'usePcntl' => false,
]; 

Source: https://github.com/bobthecow/psysh/issues/540#issuecomment-446480753

like image 159
ohho Avatar answered Oct 21 '22 01:10

ohho


This happens on Mojave when you upgrade/install PHP 7.3 using homebrew, (It's a problem with PsySh (used by Tinker) and Homebrew's PHP 7.3.0 build.)

Simple solution is, In your php.ini set

pcre.jit=0


If you don't know which ini file is used, you can run php --ini to find it,

# /usr/local/etc/php/7.3/php.ini
- ;pcre.jit=1
+ pcre.jit=0
like image 37
muhive Avatar answered Oct 21 '22 02:10

muhive