10. Command Line Tools

10.1. Flush commands

  • Flush cache elements matching the key block_id = 5:

    bin/console sonata:cache:flush --keys='{"block_id":5}'
    
  • Flush all cache elements:

    bin/console sonata:cache:flush-all
    

For more information about this, please have a look at the SonataCacheBundle documentation.

10.2. Page commands

  • Update core routes, from routing files to page manager
1
bin/console sonata:page:update-core-routes --site=all

You could also remove orphan pages with the --clean option.

1
bin/console sonata:page:update-core-routes --site=all --clean
  • Create snapshots from defined pages
1
bin/console sonata:page:create-snapshots --site=all
  • Cleanup snapshots
1
bin/console sonata:page:cleanup-snapshots --site=all --keep-snapshots=5
  • Create blocks
1
bin/console sonata:page:create-block-container --templateCode=default --blockCode=content_bottom --blockName="Left Content"
  • Clone site with pages
1
bin/console sonata:page:clone-site --source-id=1 --dest-id=2 --prefix=Foo

Please note that you can also give multiple website identifiers to some commands, this way

1
2
3
bin/console sonata:page:update-core-routes --site=1 --site=2 --site=...
bin/console sonata:page:create-snapshots --site=1 --site=2 --site=...
bin/console sonata:page:cleanup-snapshots --site=1 --site=2 --site=...

10.3. Debug Commands

  • Print page composition
1
2
bin/console sonata:page:dump-page sonata.page.cms.snapshot PAGE_ID
bin/console sonata:page:dump-page sonata.page.cms.snapshot PAGE_ID --extended
  • Render a block
1
2
bin/console sonata:page:render-block sonata.page.cms.snapshot PAGE_ID BLOCK_ID
bin/console sonata:page:render-block sonata.page.cms.page PAGE_ID BLOCK_ID