Re: [RFC] Configurable callback to dump results of expressions in `php -a`

From: Date: Sat, 16 Jan 2021 21:20:39 +0000
Subject: Re: [RFC] Configurable callback to dump results of expressions in `php -a`
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-112911@lists.php.net to get a copy of this message
Hi internals, > I've created a new RFC > https://wiki.php.net/rfc/readline_interactive_shell_result_function > adding a way to configure a callback to be called to dump the value of single-expression > statements from php -a > (and an ini setting that can be disabled to prevent that callback from being called). > > Many REPLs (Read-Eval-Print Loops) for other programming languages that I'm familiar with > print a (possibly truncated) representation of the result of expressions, but PHP doesn't. > It would be useful to allow users to extend the functionality of the default interactive php > shell (php -a), > possibly with auto_prepend_file or through use of command wrappers/aliases, or after loading > the shell. > Prior to this RFC, there was no way to extend the interactive php shell in this way. > (I've seen https://github.com/bobthecow/psysh mentioned as > an alternative for php -a while investigating this, > but that's a shell written from scratch, and doesn't have some functionality from php > -a such as tolerance of fatal errors) I've updated https://wiki.php.net/rfc/readline_interactive_shell_result_function after feedback and plan to start voting in a few days. This RFC will make the interactive shell dump non-null expression results with var_dump()/var_export() by default (https://externals.io/message/112568#112719 , https://wiki.php.net/rfc/readline_interactive_shell_result_function_straw_poll) - The dumping of expression results can be disabled through a system ini setting or at runtime ``` $ php -a Interactive shell php > 0.5*2; => 1.0 ``` Thanks, - Tyson

« previous php.internals (#112911) next »