Grav — CLI for the Grav Flat-File CMS

Practical guide to the Grav CLI tools: bin/grav for cache, backup and scheduler, and bin/gpm for installing and updating plugins and themes.

Grav is a modern PHP-based flat-file CMS: it needs no database and stores your content as plain Markdown and YAML files right in the filesystem. You manage it through two command-line tools – bin/grav for core tasks such as clearing the cache, backups and the scheduler, and bin/gpm, the Grav Package Manager, which installs and keeps plugins and themes up to date. This guide walks you through the everyday commands of both tools, from cache maintenance to a core upgrade.

bin/grav — General

bin/grav list — List all available Grav CLI commands.

bin/grav list

bin/grav help <command> — Show help for a specific command.

bin/grav help clear-cache

bin/grav new-project <path> — Create a new Grav project in a directory.

bin/grav new-project ~/sites/my-grav-site

bin/grav sandbox — Create a symlinked sandbox copy of Grav (for development).

bin/grav sandbox -s ~/grav-core ~/sites/my-sandbox

bin/grav — Cache & Clean

bin/grav clear-cache — Clear the Grav cache.

bin/grav clear-cache

bin/grav clear-cache --all — Clear all cache types (standard + images + assets).

bin/grav clear-cache --all

bin/grav clear-cache --assets-only — Clear only compiled asset cache (CSS/JS pipeline).

bin/grav clear-cache --assets-only

bin/grav clear-cache --images-only — Clear only image cache (generated thumbnails).

bin/grav clear-cache --images-only

bin/grav clear-cache --tmp-only — Clear only temporary files.

bin/grav clear-cache --tmp-only

bin/grav clean — Remove unnecessary files (vendor cruft, tests, docs).

bin/grav clean

bin/grav — Backup & Security

bin/grav backup — Create a full backup of the Grav site.

bin/grav backup

bin/grav backup --destination <path> — Create a backup to a specific directory.

bin/grav backup --destination ~/backups

bin/grav security — Run a security scan on the Grav installation.

bin/grav security

bin/grav logviewer — View Grav log entries from the command line.

bin/grav logviewer

bin/grav — Scheduler & Composer

bin/grav scheduler -i — Install the Grav scheduler cron job.

bin/grav scheduler -i

bin/grav scheduler -r — Remove the Grav scheduler cron job.

bin/grav scheduler -r

bin/grav scheduler — Run pending scheduled tasks manually.

bin/grav scheduler

bin/grav composer — Run Composer within the Grav context.

bin/grav composer update

bin/grav yamllinter — Check all YAML files for syntax errors.

bin/grav yamllinter

bin/gpm — Package Info

bin/gpm index — List all available plugins and themes from the repository.

bin/gpm index

bin/gpm index --plugins — List only available plugins.

bin/gpm index --plugins

bin/gpm index --themes — List only available themes.

bin/gpm index --themes

bin/gpm info <package> — Show detailed info about a plugin or theme.

bin/gpm info admin

bin/gpm version — Show Grav and plugin versions.

bin/gpm version

bin/gpm — Install & Uninstall

bin/gpm install <package> — Install a plugin or theme.

bin/gpm install admin

bin/gpm install <pkg1> <pkg2> — Install multiple packages at once.

bin/gpm install admin login sitemap

bin/gpm install --all-yes <package> — Install without confirmation prompts.

bin/gpm install --all-yes feed

bin/gpm uninstall <package> — Uninstall a plugin or theme.

bin/gpm uninstall simplesearch

bin/gpm — Update

bin/gpm update — Check for and install plugin/theme updates.

bin/gpm update

bin/gpm update <package> — Update a specific plugin or theme.

bin/gpm update admin

bin/gpm update --plugins — Update only plugins.

bin/gpm update --plugins

bin/gpm update --themes — Update only themes.

bin/gpm update --themes

bin/gpm self-upgrade — Upgrade the Grav core to the latest version.

bin/gpm self-upgrade

bin/gpm self-upgrade -f — Force a Grav core upgrade (re-download even if up to date).

bin/gpm self-upgrade -f

Conclusion

With bin/grav and bin/gpm you manage an entire Grav installation straight from the command line – with no database backend, because Grav keeps all content as files. Before every plugin, theme or core update, grab a full snapshot with bin/grav backup, so a failed bin/gpm update or self-upgrade can always be rolled back. Mind your file permissions, too: the web-server user needs write access to cache/, logs/, backup/ and user/, but shouldn't own the whole directory. That keeps your site both current and secure.

Further Reading

  • artisan – command-line tool of the Laravel PHP framework
  • cargo – package manager and build tool for Rust
  • composer – dependency manager for PHP