What I was trying to do is, I want to run a local php server and then open http://localhost:8000
in chrome. I made a bat file in my windows 10 OS for this. Here's my first attempt:
php -S localhost:8000 -t C:\User\Projects\Sandbox
http://localhost:8000
The problem with this was after the first line is executed the cmd get stuck in a loop of listening to the server and the second line never gets execute. Plus, I don't want to open localhost webpage first because it keep showing the error for a few secs untill php does it's thing. Now the solution I found was the following bat file:
start php -S localhost:8000 -t C:\User\Projects\Sandbox
start http://localhost:8000
This does the job, but I saw a weird behaviour. I expected the first line to open a new cmd window and execute php -S localhost:8000 -t C:\User\Projects\Sandbox
, but what it does is, it opens a new cmd window and executes this start php -S localhost:8000 -t C:\User\Projects\Sandbox
. This opens php's own shell(which has a php logo) and then goes on to execute -S localhost:8000 -t C:\User\Projects\Sandbox
in that new console.
If I do
start php
in cmd, it opens the php shell. Then, if I go-S localhost:8000 -t C:\User\Projects\Sandbox
inside that php shell, it doesn't open local server, why?When I run the bat file why doesn't
start
opens a new cmd window and putsphp -S localhost:8000 -t C:\User\Projects\Sandbox
and keep the cmd window? Instead why does it putstart php -S localhost:8000 -t C:\User\Projects\Sandbox
in that newcmd
window, exits and opens php shell?Is there any way to keep the server running in cmd window and then somehow open the localhost webpage?
start
.START "title" [/D path] [options] "command" [parameters]
. I assume it takesphp
as command to execute with-S localhost...
as parameters. But, then if I runphp -S localhost...
straightaway in cmd why doesn't it open the php shell then?