Solve the problem that php interactive command lines cannot be started normally and introduce psysh and phppsysh.

Source: Internet
Author: User
Tags php source code

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 ).

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.