PHP interactive console
The idea of this lies on the surface, but almost everyone to whom I showed this thing was surprised and asked to give them a link. Although the idea is simple, almost everyone knows about stdin and readline.
So, the interactive console is simple and very useful. With history and auto-completion.
There are, however, three questions and two problems.
1) windows. There is no readline in windows, there is no autocomplete, respectively. Only stdin. For him, the wrapper is written, but the esc-sequences of the color change, unfortunately, do not work (but you just need to fix it).
2) readline + libedit / libreadline. They need to (preferably, or rather) be installed. The last library may already be in your possession (if not, then I installed it using the “emerge libedit” command), then the php extension readlineneed to collect. This is done like this: cd php-5.xx / ext / readline && phpize && ./configure && make && make install
3) I personally had to configure libedit. The file ~ / .editrc looks something like this for me: Now about the problems. The first is that the code inside eval can be controlled with parse error, but with fatal error it cannot. Accordingly, with fatal errors, the entire console crashes. In fairness, I’ll say that I got a fatal error only a couple of times, most errors are either notice or parse error. The second problem is the curved readline extension, which does not accept the answer “no options” from the autocomplete function. I could not overcome it, and now, if you press Tab immediately or after a space, without entering a character, a list of files will be displayed,
But overall, such a console is quite useful.
Sources are on Google code , please.
PS (for those who are bored): what will the string print
So, the interactive console is simple and very useful. With history and auto-completion.
There are, however, three questions and two problems.
1) windows. There is no readline in windows, there is no autocomplete, respectively. Only stdin. For him, the wrapper is written, but the esc-sequences of the color change, unfortunately, do not work (but you just need to fix it).
2) readline + libedit / libreadline. They need to (preferably, or rather) be installed. The last library may already be in your possession (if not, then I installed it using the “emerge libedit” command), then the php extension readlineneed to collect. This is done like this: cd php-5.xx / ext / readline && phpize && ./configure && make && make install
3) I personally had to configure libedit. The file ~ / .editrc looks something like this for me: Now about the problems. The first is that the code inside eval can be controlled with parse error, but with fatal error it cannot. Accordingly, with fatal errors, the entire console crashes. In fairness, I’ll say that I got a fatal error only a couple of times, most errors are either notice or parse error. The second problem is the curved readline extension, which does not accept the answer “no options” from the autocomplete function. I could not overcome it, and now, if you press Tab immediately or after a space, without entering a character, a list of files will be displayed,
bind "^R" em-inc-search-prev
bind "^[O5C" vi-next-word
bind "^[O5D" vi-prev-word
bind "^[[1~" ed-move-to-beg
bind "^[[4~" ed-move-to-end
bind "^[[3~" ed-delete-next-char
But overall, such a console is quite useful.
Sources are on Google code , please.
PS (for those who are bored): what will the string print
for ($i='a';$i<='z';$i++) echo $i.' ';
?