2016-10-12 01:36
浏览 98

如何在Windows CLI中运行PHP脚本

I used linux for years but I got a new laptop and haven't bothered to install linux on it yet, instead I've been getting to know Windows better. cmd.exe is absolutely horrific, its so bad I regularly feel like switching back to linux. I can't use it at all. I use PowerShell instead but even thats pretty bad.

With the linux CLIs like bash, when I run a PHP script with a loop, and echo something inside the loop, it will output what I echoed onto the screen with each iteration. PowerShell doesn't do this, it just displays nothing until the script has finished running. I run a lot of web scrapers so this is a big problem for me.

Is there a PHP CLI that I can download that will work better than PowerShell? I also came across an amazing IDE called PHPStorm today, I think it might possibly let you run PHP scripts inside a built in CLI but I haven't figured it out yet. It has a built in web server, but it also lets you add your own web server, and lets you interact with MySQL databases and other impressive things like that.

图片转代码服务由CSDN问答提供 功能建议

我使用linux多年了但是我买了一台新的笔记本电脑并没有打算在它上面安装linux,而是 我一直在更好地了解Windows。 cmd.exe绝对可怕,它太糟糕我经常觉得要切换回linux。 我完全不能使用它。 我使用的是PowerShell,但即使这样也很糟糕。

使用像bash这样的linux CLI,当我运行带有循环的PHP脚本,并在循环内回显一些东西时,它会输出我在每次迭代时回显到屏幕上的东西。 PowerShell不执行此操作,它只是在脚本运行完毕之前不显示任何内容。 我运行了很多网络刮刀,所以这对我来说是个大问题。

我可以下载哪个PHP CLI比PowerShell更好用吗? 我今天也遇到了一个名为PHPStorm的神奇IDE,我想它可能会让你在内置的CLI中运行PHP脚本,但我还没想到它。 它有一个内置的Web服务器,但它也允许您添加自己的Web服务器,并允许您与MySQL数据库和其他令人印象深刻的事情进行交互。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • doukenqiong0588 2016-10-19 11:21

    You can run PHP scripts from the commandline in Windows as well. Given you have a file namned main.php you can run this file by just writing php %filename% (So php main.php) in this case. Anything written to the standard output stream will appear in the console.

    The php binary is not present in the environment path variable by default and should be added.

    点赞 打赏 评论
  • dsnpjz6907 2016-10-22 17:13

    I followed this tutorial on converting Windows 10 into something more linux like.

    I can use bash now: enter image description here

    点赞 打赏 评论

相关推荐 更多相似问题