Skip to content

Instantly share code, notes, and snippets.

@chapterjason
Last active September 14, 2017 07:05
Show Gist options
  • Save chapterjason/d99af7d37acf02f8525abe78c81dbfd9 to your computer and use it in GitHub Desktop.
Save chapterjason/d99af7d37acf02f8525abe78c81dbfd9 to your computer and use it in GitHub Desktop.
Symfony Makefile ported to windows as batch
@ECHO off
SETLOCAL EnableDelayedExpansion
FOR /f "delims=" %%x IN (.env) DO (
SET "VAR=%%x"
IF NOT "!VAR:~0,1!" == "#" (
ECHO setting %%x
SET "%%x"
)
)
SET CONSOLE=bin\console
:sf_console
IF NOT EXIST %CONSOLE% (
ECHO Run "composer require cli" to install the Symfony console.
)
IF NOT "%1" == "" (
call :%1
)
EXIT /B %ERRORLEVEL%
:cache-clear
IF NOT EXIST %CONSOLE% (
SET FOLDER=var\cache
IF EXIST "%FOLDER%" (
FOR /F %%x IN ('dir %FOLDER% /B') DO (
RMDIR /S /Q "%FOLDER%\%%x"
)
)
) ELSE (
php %CONSOLE% cache:clear --no-warmup
)
EXIT /B %ERRORLEVEL%
:cache-warmup
call :cache-clear
IF NOT EXIST %CONSOLE% (
echo Cannot warm up the cache ^(needs "symfony/console"^)
) ELSE (
php %CONSOLE% cache:warmup
)
EXIT /B %ERRORLEVEL%
:serve_as_sf
IF NOT EXIST %CONSOLE% (
call :serve_as_php
) ELSE (
FOR /F %%x IN ('php %CONSOLE% ^| FIND /I "server:start"') DO (
SET FOUND=%%x
)
IF NOT "!FOUND!" == "" (
php %CONSOLE% server:start
echo Quit the server with bin/console server:stop
) ELSE (
call :serve_as_php
)
)
EXIT /B %ERRORLEVEL%
:serve_as_php
echo Run "composer require symfony/web-server-bundle" for a better web server
php -S 127.0.0.1:8000 -t public
EXIT /B %ERRORLEVEL%
:serve
call :serve_as_sf
EXIT /B %ERRORLEVEL%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment