Skip to content

Instantly share code, notes, and snippets.

@fulopattila122
Last active December 11, 2016 15:12
Show Gist options
  • Save fulopattila122/47ce8db7428d201fefbb to your computer and use it in GitHub Desktop.
Save fulopattila122/47ce8db7428d201fefbb to your computer and use it in GitHub Desktop.
Properly clean Symfony/Sylius cache on development environment
#!/bin/bash
[ ! -d app/cache/dev ] && echo "No [app/cache/dev] folder waz found here" && exit 1
sudo echo "Symfony Cache Cleaner" || exit 1
echo -n "Clearing folder [app/cache/dev] (except for sessions)..."
ls app/cache/dev/ | grep -v sessions | grep -v feed | tr '\n' '\0' | xargs -0 -L1 -I '$' sudo rm -rf 'app/cache/dev/$'
echo OK
echo -n "Re-crating the hateoas folder..."
[ ! -d app/cache/dev/hateoas ] && mkdir app/cache/dev/hateoas && sudo chown www-data.www-data app/cache/dev/hateoas
[ $? == 0 ] && echo OK
echo -n "Re-crating the jms_serializer folder..."
[ ! -d app/cache/dev/jms_serializer ] && mkdir app/cache/dev/jms_serializer && sudo chown www-data.www-data app/cache/dev/jms_serializer
[ $? == 0 ] && echo OK
echo -n "Resetting permissions for www-data..."
sudo chown -R .www-data app/cache app/logs
sudo chmod -R g+w app/cache app/logs
echo OK
echo -n "Clearing redis cache..."
redis-cli flushdb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment