dannsbass/google-sheets

Manipulate Google Sheets using PHP

v1.0.1 2023-09-22 08:59 UTC

This package is auto-updated.

Last update: 2025-03-22 15:14:25 UTC


README

Examples of Google Sheets API implementations using PHP

Requirements

  1. PHP 7.4+
  2. a single file named credentials.json from Google

Installation

Using Composer

To install, just add the following script to your composer.json file:

{
    "require": {
        "php": ">=8.0.0",
        "dannsbass/google-sheets": "*"
    },
    "scripts": {
        "pre-autoload-dump": "Google\\Task\\Composer::cleanup"
    },
    "extra": {
        "google/apiclient-services": [
            "Sheets"
        ]
    }
}

or by running the following command:

composer require dannsbass/google-sheets

Composer installs autoloader at ./vendor/autoloader.php. to include the library in your script, add:

require_once 'vendor/autoload.php';

Install from source

Download this library from Github:

git clone https://github.com/dannsbass/google-sheets
cd google-sheets

Then include src/Dannsheet.php in your script:

require_once 'src/Dannsheet.php';

Usage

Creating a simple configuration

<?php

require_once './src/Dannsheet.php';

Dannsheet::setCredentials(__DIR__ . '/path/to/credentials.json');
Dannsheet::setSpreasheetId(YOUR_SPREADSHEET_ID); // from Google

See examples/ directory for more details.