Skip to content

Instantly share code, notes, and snippets.

@wences-dc-uba-ar
Last active June 5, 2019 13:39
Show Gist options
  • Save wences-dc-uba-ar/ff8ef8a98f0e0225ffb6fd39f8bbcb04 to your computer and use it in GitHub Desktop.
Save wences-dc-uba-ar/ff8ef8a98f0e0225ffb6fd39f8bbcb04 to your computer and use it in GitHub Desktop.
symfony snippets
#!/bin/bash
DEPLOY_DIR=$(basename `pwd`)
BUNDLES=$(php7.1 app/console debug:config|egrep -i '\| ([a-z]+) +\|'| cut -f 2 -d ' ')
for ENV in dev test preprod; do
# prod stage no funca
file=/var/www/web/debug-config/$DEPLOY_DIR/$ENV
echo $file
mkdir -p $(dirname $file)
echo "" >$file.yml
echo "" >$file-defaults.yml
for BUNDLE in $BUNDLES; do
echo "########################## $BUNDLE ##########################" >>$file.yml;
php7.1 app/console debug:config --env=$ENV $BUNDLE | egrep -v '^$|(=|#|Current config)' | >>$file.yml 2>/dev/null;
echo "########################## $BUNDLE ##########################" >>$file-defaults.yml;
php7.1 app/console config:dump-reference --env=$ENV $BUNDLE | egrep -v '^$|(=|#|Current config)' | >>$file-defaults.yml 2>/dev/null;
done
done
# symfony clear cache & warmup
php7.1 app/console cache:clear && sudo chmod -R a+rwX app/cache/
# quick clear cache
sudo rm -rf app/cache/*
# quick clear memcache
echo -e "flush_all" | netcat -w 3 localhost 11211
# agrega a cada .twig un mensaje para marcar en el html generado la ruta del template.twig que genero la seccion (inicio y fin)
# solo inyecta el mensaje en el ambiente dev
#
# exepciones:
# data-operator.html.twig
# operator-validator.html.twig
# templates que extienden otras (contienen {% extends)
#
# @TODO: ver como marcar las que extienden a otras tambien
# marca al principio
find . -iname *.twig \
! -name data-operator.html.twig \
! -name operator-validator.html.twig \
! -exec grep -q '{% extends' \
{} \; \
-exec sed -i '1i{% if app.debug %}\n<!-- twig-debug@dev {} OPEN -->\n{% endif %}' {} \;
# marca al final
find . -iname *.twig \
! -name data-operator.html.twig \
! -name operator-validator.html.twig \
! -exec grep -q '{% extends' \
{} \; \
-exec sed -i '$a{% if app.debug %}\n<!-- twig-debug@dev {} CLOSE -->\n{% endif %}' {} \;
# lista de los twigs que extienden a otras
find . -iname *.twig \
! -exec grep -q '{% extends' {} \; \
-print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment