Clear cache with after deploy hook on pagodabox

Clear cache with after deploy hook on pagodabox

pagodabox is a good alternative to host a Symfony2 site. When updating it all you need to do is commit to your master branch and push it to pagodabox, then clear the cache via ssh to deploy the site. But the last step can be automated with an after deploy hook.

An after deploy hook is is added in the boxfile and all we need to add is this:

after_deploy: - “rm -R app/cache/”

Update: Tobias Sjösten (thanks for the tip!) had an improvement to the hook, and it is to use symfonys console tool to clear the cache like this:

after_deploy:

  • “php app/console cache:clear –env=prod –no-debug”

Boxfile example

An example of a boxfile with after_deploy hook included:

web1:
  ################################################
  ## GENERAL SETTINGS
  ################################################
  shared_writable_dirs:
      - app/cache
      - app/logs

  ################################################
  ## WEB SPECIFIC SETTINGS
  ################################################
  document_root: web
  default_gateway: app.php
  index_list: [app.php]

  ################################################
  ## PHP SPECIFIC SETTINGS
  ################################################
  php_version: 5.3.5
  php_extensions:
    - intl
    - mbstring
    - xsl
    - apc
    - mysql
    - posix
    - iconv
    - tokenizer
    - xml
    - pdo_mysql
  php_session_autostart: Off
  php_short_open_tag: Off
  magic_quotes_gpc: Off
  after_deploy:
    - "php app/console cache:clear --env=prod --no-debug"