Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a better console for PHP than running in interactive mode

Is there something like ipython for PHP? Syntax highlighting and not having the console exit to shell on the first exception would be nice to haves. :)

like image 355
Kit Sunde Avatar asked Apr 23 '11 13:04

Kit Sunde


People also ask

How do I run PHP in interactive mode?

Interactive mode ¶ In this mode, a complete PHP script is supposed to be given via STDIN, and after termination with CRTL+d (POSIX) or CTRL+z followed by ENTER (Windows), this script is evaluated. This is basically the same as invoking the CLI SAPI without the -a option. As of PHP 8.1.

What is shell PHP?

Simple web shells are command-based scripts. A PHP web shell allows attackers to manage the administration of your PHP server remotely. The attackers can access it using a URL on the internet. More complex web shells can also directly access the memory.


2 Answers

Justin just gave a talk on the interactive shell Psysh at OSCON which appears to be an improved version of phpsh.

https://github.com/bobthecow/psysh

like image 72
Greg Avatar answered Oct 13 '22 01:10

Greg


The Interactive Shell will be improved in PHP 5.4.

See http://schlueters.de/blog/archives/133-Now-in-trunk-Improved-interactive-shell.html

Improved CLI Interactive readline shell (Johannes)

  • Added cli.pager ini setting to set a pager for output.
  • Added cli.prompt ini settingto configure the shell prompt.
  • Added shortcut #inisetting=value to change ini settings at run-time.
  • Don't terminate shell on fatal errors.

An alternative would be http://phpsh.org/

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.

like image 35
Gordon Avatar answered Oct 13 '22 01:10

Gordon