Grav - CLI


Advertisements


In this chapter, we will understand how the CLI works in Grav. CLI stands for command line interface stored in bin/Grav. It performs some tasks such as clearing cache, creating backup copy, etc.

Accessing CLI is different on different platforms. On Windows, you can access through cmd, on Mac you can access through Terminal and on Linux you can use shell. In windows, you can't use UNIX style commands. To use these just install the msysgit package which provides GIT and GIT BASH and provides UNIX style commands on Windows.

You can list out the available commands in the Grav by using below command −

$ bin/Grav list

You can see the available commands as shown in the following screenshot −

Grav CLI

New Project Creation

Creating new project with Grav is very simple. You can create a new project with a Grav instance.

  • Open your terminal or console and navigate to your Grav folder.

$ cd ../ProjectFolder/grav
  • Your Grav will be installed in the root of your web server. If you want to create folder called contact inside the root folder of your Grav, then use the command as −

$ bin/Grav  project-name  ../webroot/ contact

It will download all the required dependencies and create a new Grav instance.

Installing Grav Dependencies

While installing dependencies, Grav automatically installs plugins namely error plugin, problems plugin and antimatter theme. You can install these by using the following command in your terminal or console −

$ cd ../webroot/myproject
$ bin/Grav install

You will now see the downloaded plugins in their respective folders as −

  • ../webroot/ myproject/user/plugins/error

  • ../webroot/ myproject/user/plugins/problems

  • ../webroot/ myproject/user/themes/antimatter

Clearing Grav Cache

You can delete files and folders to clear the cache which are stored in the cache/ folder. To clear cache, you can use below command −

$ cd ../webroot/myproject
$ bin/Grav clear-cache

Create Backup

In Grav, you can back up your project stored under the root folder. As it won't use the database so there is no difficulty to take a backup. If you want to create the backup of your project called myproject (../webroot/myproject), then use the following command −

$ cd ../webroot/myproject
$ bin/Grav backup

You will see a zip file of the backup created under the backup/ folder.

Updating Composer

You can update the Grav composer which was installed via Github and installed manually using composer based vendor packages. The command is −

$ bin/Grav composer


Advertisements
E-Books Store