3

enter image description here

When a lot of text is printed (example User::all()), old tinker v2.7.1 prints all data. The new tinker stops with a colon (:). Is there a way to return the old behavior?

Mantas D
  • 3,993
  • 3
  • 26
  • 26
  • Does this answer your question? [View nested objects under Tinker](https://stackoverflow.com/questions/47946356/view-nested-objects-under-tinker) – N69S Dec 07 '22 at 09:58
  • Unfortunately no, it is a recent change in tinker. A bit older tinker version v2.7.1 prints all the data, but a newer version waits while you press the button to show more. – Mantas D Dec 07 '22 at 10:02
  • how do you stop the colon behavior? I type my return key and it only shows one record at a time, and when I get to the last record, it shows END, and I cannot procede unless I exit out of tinker, and re-enter. – Robert Bryan Davis Dec 12 '22 at 18:53

2 Answers2

5

Tinker uses Psysh.

Psysh has a config option for setting pager.

From https://github.com/bobthecow/psysh/wiki/Config-options

If this is not set, it falls back to less. It is recommended that you set up cli.pager in your php.ini with your preferred output pager.

For anything more than one page long, less will interrupt output with a colon.

I fixed this by switching the pager to 'cat'.

To update psysh options for tinker, create a .psysh.php file in the laravel project root directory and throw this in it:

<?php

return [
    'pager' => "cat"
];

Now when you run tinker, you'll get uninterrupted output (like it used to be).

Dubnut
  • 51
  • 4
  • 3
    You can set pager to `false` rather than `'cat'` and save yourself piping output to a new process every time :) – bobthecow Jan 21 '23 at 14:44
0

Whilst setting pager to false does work for me (thanks to @bobthecow for the help with that in the comments) I wanted a solution that didn’t require adding .psysh.php to all my projects.

For anyone else who's experiencing this, as far as I can tell, it turns our that if you have never had the pcntl extension installed, Psysh has never used a pager: https://github.com/bobthecow/psysh/blob/v0.11.20/src/Configuration.php#L1240

I had recently installed this and so everything started going through less. I prefer the previous behaviour in that all tinker output is in my actual terminal and shell, so I reverted to the previous behaviour by exporting the TERM=dumb variable.

I'm running in alpine on Docker so my existing TERM was xterm. No idea if this has any knock-on effects but so var it seemingly works as before installing the extension.

Thomas Nadin
  • 1,167
  • 10
  • 22