Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

howi's avatar
Level 6

Tinker history

I use Linuxmint and XAMPP. When I use tinker, I can't use the command's history, like in Terminal, and I have to type again each command. Is there any trick to have it working on Linux?

0 likes
9 replies
D9705996's avatar

tinker saves the history to ~/.config/psysh/psysh_history so might be worth checking if this file/folder exists in your filesystem.

What happens if you run history within a tinker session. If I do se I can see the list of commands I have run e.g.

php artisan tinker 
Psy Shell v0.9.9 (PHP 7.3.0 — cli) by Justin Hileman
>>> history
0: DB::connection()->enableQueryLog();
1: factory('App\ConfigurationItem', 10)->create();
2: DB::connection()->enableQueryLog();
3: ConfigurationItem::all()->update(['is_active' => 1]);
4: ConfigurationItem::update(['is_active' => 1]);
5: ConfigurationItem::where('is_active',0)->update(['is_active' => 1]);
6: DB::getQueryLog();
7: User::first();
8: exit
1 like
howi's avatar
Level 6

That file exists, but its size is 0.

ls -al ~/.config/psysh/
totale 8
drwx------  2 marco marco 4096 ott  9 15:30 .
drwxr-xr-x 45 marco marco 4096 dic 13 16:35 ..
-rw-rw-r--  1 marco marco    0 ott  9 15:30 psysh_history

and when I run history within Tinker I get this

php artisan tinker
Psy Shell v0.9.9 (PHP 7.2.11 — cli) by Justin Hileman
>>> history 
>>> 

and when I click on arrow up, down, ... I get this

php artisan tinker
Psy Shell v0.9.9 (PHP 7.2.11 — cli) by Justin Hileman
>>> history 
>>> ^[[A^[[B^[[D^[[C

Maybe I should change some configuration file?

D9705996's avatar

After a bit of googling this might be a php issue rather than tinker. Readline support is needed and you can test/confirm following this stack overflow

https://stackoverflow.com/a/36201486

If you run php -i and look at configure command it should contain --with-readline. If not your going to have to look at reinstalling/compiling your php

howi's avatar
Level 6

Thank you D9705996.

That's the problem.

php -a
Interactive mode enabled

I get no prompt.

And with php -i I can see that Configure Command doesn't have the option --with-readline.

Now, I'm used to XAMPP and I don't want to switch to the packages of my Linuxmint. I'm going to look for adding a new PHP version, compiled --with-readline, but at the moment I don't know how.

Any advice is welcome.

howi's avatar
Level 6

Thank you. It seems to be a way to install PHP from a different repository. Maybe I'll try after my current try. I'm trying to follow the guide to add a different PHP version on XAMPP

 http://localhost/dashboard/docs/use-different-php-version.html

It is available after you've installed XAMPP, but I haven't found it on the internet.

It requires to rebuild PHP and now I'm stuck, but I'll keep you informed.

howi's avatar
Level 6

Ok. That's the story. I don't think you should loose your time reading about my tries to use a different PHP Version. I really made a mess and now I switched back to the start point.

Includes all necessary compilation tools

    sudo apt install build-essential

Stop your Apache server

    sudo /opt/lampp/lampp stop

Back up your current XAMPP PHP files

    mv /opt/lampp/php /opt/lampp/php.old
    mv /opt/lampp/etc/php.ini /opt/lampp/etc/php.ini.old
    mv /opt/lampp/modules/libphp7.so /opt/lampp/modules/libphp7.so.old

Create a tmp directory

    mkdir tmp

Download a PHP version from the PHP website

Extract the contents of the compressed archive file and move all to the /tmp directory.

I am in /opt/lampp

    mv /home/marco/Scaricati/php-7.3.0/* tmp/

Configure and build PHP in the usual manner.

I think it should take 3 steps: ./configure, make, make install

I made my tries, but I can't complete the configuration.

First I add --with-readline to the Configure Command and I got an error because of perl and, as I use XAMPP, I added a link

    ln -s /opt/lampp/bin/perl /bin/perl

I got another error. After some reaserches

    apt install libc-client-dev

Then the terminal asked me to add --with-kerberos and the Configure Command became this

./configure  --prefix=/opt/lampp --with-apxs2=/opt/lampp/bin/apxs --with-config-file-path=/opt/lampp/etc --with-mysql=mysqlnd --enable-inline-optimization --disable-debug --enable-bcmath --enable-calendar --enable-ctype --enable-ftp --enable-gd-native-ttf --enable-magic-quotes --enable-shmop --disable-sigchild --enable-sysvsem --enable-sysvshm --enable-wddx --with-gdbm=/opt/lampp --with-jpeg-dir=/opt/lampp --with-png-dir=/opt/lampp --with-freetype-dir=/opt/lampp --with-zlib=yes --with-zlib-dir=/opt/lampp --with-openssl=/opt/lampp --with-xsl=/opt/lampp --with-ldap=/opt/lampp --with-gd --with-imap=/bitnami/xamppunixinstaller72stack-linux-x64/src/imap-2007e --with-imap-ssl --with-gettext=/opt/lampp --with-mssql=shared,/opt/lampp --with-pdo-dblib=shared,/opt/lampp --with-sybase-ct=/opt/lampp --with-mysql-sock=/opt/lampp/var/mysql/mysql.sock --with-mcrypt=/opt/lampp --with-mhash=/opt/lampp --enable-sockets --enable-mbstring=all --with-curl=/opt/lampp --enable-mbregex --enable-zend-multibyte --enable-exif --with-bz2=/opt/lampp --with-sqlite=shared,/opt/lampp --with-sqlite3=/opt/lampp --with-libxml-dir=/opt/lampp --enable-soap --with-xmlrpc --enable-pcntl --with-mysqli=mysqlnd --with-pgsql=shared,/opt/lampp/ --with-iconv=/opt/lampp --with-pdo-mysql=mysqlnd --with-pdo-pgsql=/opt/lampp/postgresql --with-pdo_sqlite=/opt/lampp --with-icu-dir=/opt/lampp --enable-fileinfo --enable-phar --enable-zip --enable-intl --disable-huge-code-pages --with-readline --with-kerberos

Then

    apt install libkrb5-dev

And then it asked me where is postgresql, so I removed --with-pdo-pgsql=/opt/lampp/postgresql and --with-pgsql=shared,/opt/lampp/

Now it asks me to reinstall readline.

That's enough!

I summarized the story.

I'm going to keep tinker as it is.

Talinon's avatar

I use Linux Mint, and my tinker history works fine - but I vaguely recall having a similar issue.

I think I installed readline as a module:

sudo apt-get install php7.0-readline

I might have also set my keyboard configuration to resolve the cursor issue:

sudo dpkg-reconfigure keyboard-configuration

howi's avatar
Level 6

Thank you Talinon. I think that the problem is that I am using XAMPP and then I can't simply install php7.0-readline. I started to use XAMPP because it's easy to do a lot of things, like create virtual hosts. Now, I am thinking to install all the staff directly with Linuxmint, again. I will try in a virtual machine first.

Please or to participate in this conversation.