Macintosh doesn't have mac os php native mode

I try to run PHP interactively from a terminal window and when I run a command

php -a 

he says "Interactive mode is on", but does not show me the hint "php->". I have to press the z control button to exit interactive mode, but I can execute any commands while interactive mode is β€œon”

Does anyone know how to fix this.

+8
php terminal macos
source share
3 answers

The PHP interactive shell requires GNU readline or libedit to be statically placed in the PHP binary. Many distributions provide only shared libraries containing only the readline extension.

If you compile PHP yourself,

 ./configure --with-readline 

or

 ./configure --with-libedit 

(note that you may not be able to redistribute the PHP binaries associated with readline due to incompatibility between the GPl and the PHP license, then you will have to use libedit, but I doubt you want to redistribute PHP anyway. of course, this ok, that doesn't matter for your PHP base applications, but that's one of the reasons why this doesn't work for most distributions ...)

Edit: I just logged a PHP error to enable readline mode along with the general assembly, maybe I take the time to implement it: http://bugs.php.net/bug.php?id=53878

+5
source share

There is a solution (emulator) that works very well for me:

http://www.fischerlaender.net/php/phpa-norl

+4
source share

There is another great solution (created by Facebook btw) phpsh

In your own words:

phpsh is an interactive shell for php, which includes reading history, tab, quick access to documentation. It was developed on Facebook and, ironically, written mostly in python. It is open source and released under the BSD license.

I've been using it for a while, and it's really good, in many ways even better than just php -a

+2
source share

All Articles