Kirby plugin to write data to Google Sheets

0.5 2020-02-07 11:06 UTC

This package is auto-updated.

Last update: 2023-03-07 18:12:41 UTC


Normally, Kirby doesn't provide a way to save data to a database. You can actually, with using the DB driver. The problem with this is that Kirby Panel doesn't provide an easy way to make this data viewable or exportable.

This package focuses on saving to an external system, namely Google Sheets.


You can install the package via composer:

composer require wearejust/kirby-sheets


You can save data to Google Sheets using the following code.

use Wearejust\KirbySheets\Connector;

$connector = new Connector();
$data = ['first_name' => 'Foo', 'last_name' => 'Bar'];

$connector->append($spreadsheetId, $sheetName, $data);

It is important that you first create a Google Secret auth file. This file is important because it sets some permissions stuff. You can create your auth file using this guide -> https://www.fillup.io/post/read-and-write-google-sheets-from-php/

In your Kirby config.php file, you can set the path to the file:

    'wearejust/kirby-sheets' => [
        'authentication_file' => __DIR__ . '/../../google.prod.json',

Usage with KirbyUniform

Most the time, you will probably use Kirby Uniform. We've created an custom action using the following code:

    if ($kirby->request()->is('POST')) {
        $sheetName = 'TAB X';
        $spreadsheetId = 'SPREADSHEETID_OF_GOOGLE'
            ->action(new SaveToGoogleSheetsAction($form, [
                'spreadsheetId' => $spreadsheetId,
                'name' => $sheetName,
                'exclude' => ['gdpr'], // You can use the exclude option to exclude keys from the form data

        return Header::redirect('/thanks');


The MIT License (MIT).