Windows 下有没有简单的 php shell?
Windows 下有可用的命令行 php shell 吗?我正在寻找类似于 python shell 的东西,它允许我打开并立即开始执行代码。
Is there a command line php shell available for windows? I looking for something similar to the python shell, that will allow me to open and immediately begin executing code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
PHP 的 Windows 命令行: http://php.net/manual/ en/install.windows.commandline.php
There is the windows command line for PHP: http://php.net/manual/en/install.windows.commandline.php
试试这个:
将此代码保存到文件(例如 shell.php),然后从控制台运行它:
按 CTRL+C 退出。
Try this:
Save this code to a file (eg shell.php) and then run it from console:
Hit CTRL+C to exit.
看看使用
-a
参数运行 php.exe,或者使用 phpsh项目。Have a look at either running php.exe with the
-a
argument, or maybe the phpsh project.另一个简单的变体,受到其他答案的影响。创建并运行以下 cmd 脚本:
立即执行,Ctrl+C 退出。在“php.exe”之前插入正确的路径。
Another simple variant, influenced by other answers. Create and run the following cmd-script:
Immediate execution, Ctrl+C for exit. Insert correct path before "php.exe".
有 php-shell - 它不是很好,但仍然比
php -a
. (此外,安装非常简单,只需运行pear install http://jan.kneschke.de/assets/2007/2/17/PHP_Shell-0.3.1.tgz
。)还有phpa-norl,但我还没有尝试过。There is php-shell - it is not great, but still way better than
php -a
. (Also, it is dead simple to install, just runpear install http://jan.kneschke.de/assets/2007/2/17/PHP_Shell-0.3.1.tgz
.) There is also phpa-norl, but I haven't tried it.我也在 github 上找到了这两个:
ubermuda/PHPInteractiveShell
https://github.com/ubermuda/PHPInteractiveShell
d11wtq/boris · 非 Windows
https://github.com/d11wtq/boris
I found these two on github as well:
ubermuda/PHPInteractiveShell
https://github.com/ubermuda/PHPInteractiveShell
d11wtq/boris · non windows
https://github.com/d11wtq/boris
PsySH 是我最近见过的最好的 REPL shell。 Tab 补全、phpdoc 支持、正确的命名空间处理、交互式调试、插件支持等等。它是纯 PHP 并具有 Composer 支持,因此应该很容易在 Windows 上安装。我只在 Linux 上尝试过,但看看代码,它似乎甚至在没有 readline 的操作系统上有一些历史支持。
PsySH is the best REPL shell I have seen recently. Tab-completion, phpdoc support, proper namespace handling, interactive debugging, plugin support and many more. It is pure PHP and has composer support so it should be easy to install on Windows. I have only tried it on Linux but looking at the code, it seems to even have some history support on OSes without readline.
@Pavle Predic 的答案(https://stackoverflow.com/a/15742101/2752670)在 Windows 上适用于我。
但我想在任何地方使用
shell.php
文件,所以我的解决方案是:新建并保存
shell.php
到 php 安装目录(或者你喜欢的其他地方) ),例如C:\Program Files\php-5.6.12-Win32-VC11-x64\shell.php
新建一个Windows环境变量,键:
shell.php
,值:"C:\Program Files\php-5.6.12-Win32-VC11-x64"
重新启动计算机
在系统中的任何位置使用:
php %shell.php%
@Pavle Predic 's answer (https://stackoverflow.com/a/15742101/2752670) works for me on Windows.
But I want to use the
shell.php
file anywhere, so my solution is:new and save
shell.php
in php installed dir (or where else you like), e.g.C:\Program Files\php-5.6.12-Win32-VC11-x64\shell.php
new a Windows environment variable, key:
shell.php
, value:"C:\Program Files\php-5.6.12-Win32-VC11-x64"
restart computer
use anywhere in the system:
php %shell.php%
也许回答 - 阅读此处:https://stackoverflow.com/a/19085620/2480481
我想我找到了最简单的方法,因为我对自己使用非常感兴趣:)
我尝试了这里和其他一些论坛/页面的所有选项... Windows 无法使用 readline。
Maybe answered - Read here: https://stackoverflow.com/a/19085620/2480481
I think i found easiest way to do it because im so interested to use myself :)
I try all options from here and from some other forums/pages... Windows cannot use readline.