Solve the problem that php interactive command lines cannot be started normally and introduce psysh and phppsysh.
Today, I tried to start the interactive php Command Line on my mac computer. I found that I had been stuck in the prompt place after I typed the command, but no prompt was displayed, baidu should be related to readline.
Therefore, the php readline extension is installed. Find the source code directory of the readline extension in the php source code directory and install the extension using the phpize command.
Phpize./configure -- with-php-config = php-config tool directory makemake install
Then add the extension in php. ini:
extension=readline.so
Run php-m | grep readline to check whether the extension takes effect. Note that the cli extension is installed here, so it has nothing to do with cgi, so you do not need to restart php-fpm. For more information, see the official document Readline. "The readline Extension function provides interfaces for accessing the GNU Readline library. these functions provide editable command lines. in Bash, you can use arrow buttons to insert characters or read history commands. because of the Interaction feature of this library, this function is of little use in the Web programs you write, but it is very useful when the scripts you write are used in command lines."
Therefore, if you want to use php repl, you need to install this extension. During installation, note that the GNU Readline library should be included in the system, because php readline needs to access the interface of this library. Without this library, many interactive command lines cannot be used normally. For example, when you press the direction key, you cannot move the cursor, but garbled characters appear.
Run php-a on the command line to start repl. In addition, some foreign people have made a repl that is a little better than php native repl, called psysh. If you are interested, you can check it out.
In linux, there are usually readline tools and packages that support this tool. It provides interactive text editing. Many languages and tools, such as python, node, and ruby, also provide interactive command line tools. They can also be called interactive interpreters, the abbreviation is REPL (read-eval-print-loop ).