mac os php intratactive mode has no prompt
Asked Answered
H

3

9

I'm trying to run PHP in interactive mode from the terminal window and when i run the command

  php -a

it says "Interactive mode enabled" but does not show me the "php->" prompt that it should. I have to press control z to get out of interactive mode but I can execute any commands while interactive mode is "enabled"

Does anyone know how to fix this

Habakkuk answered 29/1, 2011 at 12:38 Comment(0)
M
5

The PHP interactive shell requires that GNU readline or libedit is compiled statically into the PHP binary. Many distributions only provide shared libraries containing only the readline extension.

If you compile PHP yourself do

./configure --with-readline

or

./configure --with-libedit

(note that you, probably, may not redistribute PHP binaries linked to readline due to incompatibilities between GPl and the PHP license, you'd have to use libedit then, but I doubt you want to redistribute PHP itself anyways. Usage is certainly ok. This doesn't matter for your PHP-base applications. But this is one of the reasons why this doesn't work for most distros ...)

Edit: I just filed a PHP bug to enable readline mode with a shared build, too, maybe i find time to implement it: http://bugs.php.net/bug.php?id=53878

Macronucleus answered 29/1, 2011 at 12:47 Comment(3)
is there a way I can determine if those are installed or not should they be listed in php info ?Habakkuk
If it is installed phpinfo will list readline. You can also check php -m. To see if it was statically try running php -nm. If "readline" is listed it should work.Macronucleus
Interactive Shell vs. Interactive ModeTopside
P
4

There is a solution (emulator) which works pretty well for me:

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

Precipitous answered 10/2, 2011 at 21:48 Comment(0)
G
2

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

In their own words:

phpsh is an interactive shell for php that features readline history, tab completion, quick access to documentation. It was developed at Facebook and ironically, is written mostly in python. It is open source and released under a modified BSD license.

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

Gardner answered 10/11, 2012 at 22:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.