doubipeng1336 2016-10-12 01:36
浏览 128
已采纳

如何在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.

  • 写回答

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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?