0

I´m trying to run a website locally from a batch file on windows.

I am coding a project and want later to start this over xampp on a USB stick, to run that everywhere I want it to. Already tried to use some shell with PHP and start commands. But it´s not running in the expected ways....

C:\xampp\php\php D:\projects\project_x\index.php

AND

start D:\projects\project_x\index.php

I expected my website.... but the first command it is just putting it in my command line out...

the second shows just my code in the browser. Obviously without PHP.... so how to get that running over the xampp webserver and calling it then in my browser??

Wollhaar
  • 182
  • 3
  • 22

2 Answers2

0

Thanks to that dude above, i got the right answer :D And it´s a mix of his code and that what i have already tried.

Instead try to call it over the webserver, I have just to call the url over an browser.

Means:

start http://localhost/project_x/index.php

Wollhaar
  • 182
  • 3
  • 22
-1

Get your web server and portable browser of choice working on your flash drive.

Batch file:

@REM Open php files in a portable browser in a portable web server with a win10 64-bit batch file
@echo off
setlocal enableextensions 
%~d0\xampp\xampp_start.exe
rem if an instance of the browser is running the batch will not pause and the web server will be stopped.
taskkill /im GoogleChromePortable.exe> NUL 2>&1 
"%~d0\GoogleChromePortable\GoogleChromePortable.exe" http://localhost/applications.html http://localhost/index.php 
echo. 
%~d0\xampp\xampp_stop.exe 
exit

You should not use any software that is not on your flash drive but if you do:

If the default browser is IE11 you can only open one page / file / tab. The following command will not stop the batch file and pause must be used to keep the web server from stopping.

start http://localhost/index.php

begin will not work
start http://localhost/applications.html http://localhost/index.php 
start "" http://localhost/applications.html http://localhost/index.php 
start "" /wait http://localhost/applications.html http://localhost/index.php 
start "" "%ProgramFiles%\Internet Explorer\iexplore.exe" http://localhost/applications.html http://localhost/index.php 
"%ProgramFiles%\Internet Explorer\iexplore.exe" %22http://localhost/index.php%22%20%22http://localhost/applications.html%22
"%ProgramFiles%\Internet Explorer\iexplore.exe" http://localhost/index.php%20http://localhost/applications.html
"%ProgramFiles%\Internet Explorer\iexplore.exe" http://localhost/index.php http://localhost/applications.html
  end will not work 
somebadhat
  • 744
  • 1
  • 5
  • 17
  • 2
    Please add some explanation to your code - how does running `iexplore.exe` "start" a PHP file? – Nico Haase Apr 04 '19 at 13:01
  • 1
    he´s right. There is an default way with `start` what is starting just the default browser of your system. And to move the project files to `htdocs` is not necessary. You can tell xampp, where to load the project files. – Wollhaar Apr 04 '19 at 13:05
  • ok but i don´t want to use the iexplorer.... and you gave me already a plausible URL so could, used it to construct my solution. thanks for that. – Wollhaar Apr 04 '19 at 13:38