Skip to content

CLI commands

P2Lab Cache adds Symfony console commands you can call from bin/console. All commands work the same way the rest of Shopware’s CLI does — they respect --env=prod, return non-zero exit codes on failure, and integrate with deployment tooling.

Clears every cached page from the backend.

Terminal window
bin/console p2lab:cache:clear

Exit codes

  • 0 — success; the number of files removed is printed
  • non-zero — an exception was raised during clearing; see the message

Typical use

Run as the last step of a production deployment, after cache:clear and any migrations:

Terminal window
bin/console plugin:refresh
bin/console plugin:update P2LabCache
bin/console cache:clear
bin/console p2lab:cache:clear

Shopware’s standard commands you should know

Section titled “Shopware’s standard commands you should know”

P2Lab Cache hooks into Shopware’s standard CLI primitives. The following commands matter:

Clears the Symfony application cache. This also drops any pages stored in the Filesystem backend (because they live under var/cache/). Run after deployments.

Processes the async message queue. P2Lab Cache uses it for cache warming and a few invalidation paths. Run as a long-lived process in production.

Processes scheduled tasks — including the three nightly cleanup tasks shipped by P2Lab Cache (see Scheduled tasks).

Lists every scheduled task in the system. Look for entries beginning with p2lab_cache. to confirm the plugin’s tasks are registered.

The plugin’s REST API is the recommended way to script cache operations beyond clearing. For example, to start a warmup from a deploy script:

Terminal window
TOKEN=$(curl -s -X POST https://shop.example.com/api/oauth/token \
-H "Content-Type: application/json" \
-d '{"grant_type":"client_credentials","client_id":"...","client_secret":"..."}' \
| jq -r '.access_token')
curl -X POST https://shop.example.com/api/_action/p2lab-cache/warmup/start \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"salesChannelId":null,"batchSize":100}'

See REST API for the full endpoint list.