Reputation: 1693
I would like to make a file/script (like maybe an icon) as to run a php project with single click on my localhost. I am on Windows OS and been using XAMPP. Also the project has a MySQL database. An .exe file would have been great but I tried "EXEOUTPUT FOR PHP 1.7" but it cannot connect with my MySQL database.
So I thought can a SCRIPT/FILE be made which can start my Xampp, Apache server, MySQL and then automatically run my project which is in htdocs folder.
Upvotes: 1
Views: 3120
Reputation: 11
I have made a batch file which will allow to open the web based app using XAMPP which required one click you can also modify the shortcut using custom icon that explanation is available in my blog which can read with full modifications.
This is the sample batch code just modify the location and project name.
@echo off
tasklist /fi "imagename eq xampp-control.exe" 2>NUL | find /I /N "xampp-control.exe">NUL
if "%ERRORLEVEL%"=="0" (
echo XAMPP control panel is already running
TASKKILL /F /IM xampp-control.exe
) else (
echo XAMPP close
)
rem Check for Aapavhe
netstat -ano | find ":80" > nul
if not errorlevel 1 (
echo Apache running,Stop it
TASKKILL /F /IM apache.exe
) else (
echo Apache running
)
rem Check if MySQL running
netstat -ano | find ":3306" > nul
if not errorlevel 1 (
echo MySQL is already running
TASKKILL /F /IM mysqld.exe
) else (
echo MySQL stopped
)
rem Start the XAMPP
start "" "C:\xampp\xampp-control.exe"
rem Open the project URL in the browser
start "" "http://localhost/projectname"
rem Add a delay of 3 sec
timeout /T 3
rem Close the prompt
start /B exit
Check for Explanation: Here On my blog for more description.
Upvotes: 1
Reputation: 1676
I have create a .bat file which allows user run program
create test.bat file (for windows) and paste below code
@echo off
cd "D:\xampp\" //your xammp path
start xampp_start.exe
TIMEOUT 10 //set timeout until xampp control fully start
cd "C:\Program Files\Google\Chrome\Application" //your chrome path
start chrome.exe 127.0.0.1\myProjectName //your url
exit
Before Executing file please remove all comments
ALSO HAVE TO KEEP THE BATCH FILE IN THE SAME DRIVE AS XAMPP
Upvotes: 5