In some cases, you might experience problems when running php artisan tinker in a shared hosting environment. The problem might be similar to this:


  Unable to create PsySH runtime directory. Make sure PHP is able to write to /run/user/10057 in order to continue.

To resolve this issue, create the folder ~/.config/psysh/ and the file ~/.config/psysh/config.php. The contents should be like this. When you have SSH access, you can run the snippet below.

return [
    'runtimeDir' => '~/tmp'

Note: ~ equals the home folder and gets automatically resolved. For DirectAdmin and cPanel this is /home/username/ and for Plesk this is /var/www/vhosts/hoofddomeinnaam.

SSH command for fixing php artisan tinker  Psy\Exception\RuntimeException
 Unable to create PsySH runtime directory

mkdir ~/.config/psysh/ -p
echo "<?php
return [
    'runtimeDir' => '~/tmp'
];" >> ~/.config/psysh/config.php