Last active
August 29, 2015 14:12
-
-
Save maravedi/2a68ccee910e6c5119a7 to your computer and use it in GitHub Desktop.
Windows Batch File to Initialize Development Environment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rem I use this batch to make it easier to get going on my development. | |
rem Dump this script in your projects folder and then type 'dev myproject' | |
rem to start up an artisan serve on the myproject folder and to open up that | |
rem same folder in sublime. | |
rem Also, if you have mysql installed as a windows service and you will need that, | |
rem you can use the -m switch to fire up mysql (or -s to stop mysql). | |
rem This script is very basic, so there are probably many bugs in it. | |
@echo off | |
IF "%1"=="-s" goto STOPMYSQL | |
IF "%1"=="-m" goto START_MYSQL_1 | |
IF "%2"=="-m" goto START_MYSQL_2 | |
IF "%1"=="" got START | |
@echo off | |
dir | findstr /I /e /C:"%1" | |
if %ERRORLEVEL% == 0 goto OPEN_PROJ_1 | |
if %ERRORLEVEL% == 1 goto EXIT | |
:START | |
set status= | |
for /f "tokens=2*" %%a in ('sc query mysql ^| findstr STATE') do set status=%%b | |
if /i "%status:~0,1%"=="1" GOTO A | |
if /i "%status:~0,1%"=="4" GOTO B | |
rem if [%status%]==[4 RUNNING] GOTO B | |
rem if [%status%]==[1 STOPPED] GOTO A | |
:A | |
cls | |
echo #################################Projects#################################### | |
dir /a:d /b | |
echo ############################################################################# | |
echo (Type "exit" to quit or "cancel" to go back) | |
set /p dirName=Which project do you want to work on? | |
if /I [%dirName%]==[Exit] goto EXIT | |
if /I [%dirName%]==[Cancel] goto START | |
if /I NOT [%dirName%]==[Cancel] goto CHECK | |
if /I NOT [%dirName%]==[Exit] goto CHECK | |
:CHECK | |
@echo off | |
dir | findstr /I /e /C:"%dirName%" | |
if "%ERRORLEVEL%"=="0" goto DEV | |
if "%ERRORLEVEL%"=="1" echo That is not a valid project. | |
goto A | |
:DEV | |
set /p startMysql=Do you need mysqld? [Yes or No] | |
if /I [%startMysql%]==[Yes] net start mysql | |
start /max sublime_text %dirName% | |
cd %dirName% | |
php artisan serve | |
:B | |
echo mysqld is already running. | |
set /p terminateNow=Do you want to stop mysqld? [Yes or No] | |
if /I [%terminateNow%]==[Yes] goto X | |
if /I [%terminateNow%]==[No] goto Z | |
if /I [%terminateNow%]==[Exit] goto EXIT | |
if /I [%terminateNow%]==[Cancel] goto START | |
:X | |
echo This is X | |
net stop mysql | |
:Z | |
goto A | |
:START_MYSQL_1 | |
net start mysql | |
IF "%2"=="" echo "You didn't supply a project" & goto EXIT | |
@echo off | |
dir | findstr /I /e /C:"%2" | |
if %ERRORLEVEL% == 0 goto OPEN_PROJ_2 | |
goto EXIT | |
:START_MYSQL_2 | |
net start mysql | |
IF "%1"=="" echo "You didn't supply a project" & goto EXIT | |
@echo off | |
dir | findstr /I /e /C:"%1" | |
if %ERRORLEVEL% == 0 goto OPEN_PROJ_1 | |
goto EXIT | |
:STOPMYSQL | |
net stop mysql | |
goto EXIT | |
:OPEN_PROJ_1 | |
start /max sublime_text %1 | |
cd %1 | |
php artisan serve | |
:OPEN_PROJ_2 | |
start /max sublime_text %2 | |
cd %2 | |
php artisan serve | |
:EXIT | |
quit>nul 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I wrote this before I began using Homestead. This was back when I was just using
php artisan serve
and SublimeText for development.