PHPackages                             forikal-uk/capture-lookups - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. forikal-uk/capture-lookups

Abandoned → [https://github.com/xmlsquad/capture-lookups](/?search=https%3A%2F%2Fgithub.com%2Fxmlsquad%2Fcapture-lookups)Library[File &amp; Storage](/categories/file-storage)

forikal-uk/capture-lookups
==========================

Grabs Google Sheets and stores their data as CSV files

v0.3.3(7y ago)0111[1 issues](https://github.com/xmlsquad/capture-lookups/issues)Apache-2.0PHPPHP &gt;=7.1CI failing

Since Jun 4Pushed 6y ago1 watchersCompare

[ Source](https://github.com/xmlsquad/capture-lookups)[ Packagist](https://packagist.org/packages/forikal-uk/capture-lookups)[ RSS](/packages/forikal-uk-capture-lookups/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (7)Versions (7)Used By (0)

capture-lookups
===============

[](#capture-lookups)

A Symfony Console command. Searches for configuration file that lists URLs of Google Sheets, grabs the Sheets and stores their data locally as CSV files.

Designed be used in the context of the Symfony Console application at  which, in turn, is used in the context of a known directory structure which is based on [xml-authoring-project](https://github.com/xmlsquad/xml-authoring-project).

Usage instructions
==================

[](#usage-instructions)

Specifying the Lookup tables to collect
---------------------------------------

[](#specifying-the-lookup-tables-to-collect)

We assume this command is run in the context of an [xml-authoring-project](https://github.com/xmlsquad/xml-authoring-project). ie. the key aspects of the structure of the directory is known.

Use the `mapping.yaml` configuration file which defines the locations of the Google Sheets we must collect.

### Example mapping.yaml

[](#example-mappingyaml)

```
LookupTableA:
  # (string) Specifies the URL of the sheet to look into
  url: "https://docs.google.com/spreadsheets/d/1jOfsClbTj15YUqE-X2Ai9cvyhP-GLvP8CGZPgD1TysI/edit#gid=0"
  # (int) Sets at what row number we'll start reading data - use if you want to skip the beginning of the sheet, for example a header
  startingFromRow: 2

  # (bool) Enable or disable fetching data in a batch. Doing so is faster, but may fail if there is a lot of data to be fetched
  batchGet: true

LookupTableB:
  url: "https://docs.google.com/spreadsheets/d/1jOfsClbTj15YUqE-X2Ai9cvyhP-GLvP8CGZPgD1TysI/edit#gid=0"
  startingFromRow: 2
  batchGet: false
```

Using the command
-----------------

[](#using-the-command)

1. Checkout the repository
2. Install dependencies with `composer install`
3. Put a `gApiServiceAccountCredentials.json` file in the project root or anywhere in any of the parent directories accessible to PHP
4. Issue `bin/capture-lookups` to see all available mappings
5. Issue `bin/capture-lookups --sheet=LookupTableA` to run the command interactively
6. Issue `bin/capture-lookups --sheet=LookupTableA --no-interaction` to run the command without any prompts, skipping risky file names or existing files
7. Issue `bin/capture-lookups --sheet=LookupTableA --no-interaction --force` to run the command without any prompts, **overwriting existing files** and **using sanitised file names**

Unit testing
------------

[](#unit-testing)

1. Install dependencies
2. Run `./vendor/bin/phpunit`

Skipped Tabs - Naming convention
--------------------------------

[](#skipped-tabs---naming-convention)

By *Google Sheet tab* I mean one of the sheets *within* a workbook.

Any Google Sheet tab which has a trailing underscore will be considered to be skipped.

- `foo_` *is* skipped.
- `foo` is not skipped.
- `_foo` is *not* skipped either.

Connecting to GSuite
--------------------

[](#connecting-to-gsuite)

The file that Google Api uses to authenticate access to GSuite should be in the root of the [xml-authoring-project](https://github.com/xmlsquad/xml-authoring-project).

The [ping-drive project explains how to get set up to connect to GSuite](https://github.com/xmlsquad/ping-drive#usage).

Run the command
---------------

[](#run-the-command)

When the command is run, it will:

- Search for the XmlAuthoringProjectSettings.yaml in the current working directory, if not found it will look in the parent recursively until a file named XmlAuthoringProjectSettings.yaml is found.
- Determine the `DestinationDirectory` to write-to:
    - If `DestinationDirectory` option is passed to command, use that.
    - If no `DestinationDirectory` option is passed to command, set it to the default `DestinationDirectory` (see below).
        - The default `DestinationDirectory` is the working directory in which the command was invoked.
- For each Lookup table specified in the configuration file:
    - Go to the Google Sheet on GSuite
    - Determine and note the name of the Google Sheet
    - For each tab in that sheet:
        - If the tab's name indicates it should be ignored (has a trailing underscore), ignore that tab, skip and move on to the next tab.
        - Else, note the tab name
        - Combine the Google Sheet name with the tab name to set the resulting CSV file's name: `-.csv`.
        - Check the name to ensure it is made of only alphanumeric characters, dot, hyphen or underscore. (i.e the name is less likely to cause issues if used as a filename on Windows or MacOS)
        - If the name contains invalid characters, write a meaningful error message to STD\_OUT and STD\_ERR and exit with an error code.
        - Check to see if a CSV file matching that name is already stored in the destination directory
        - If it is already present and the `-f` (--force) flag is NOT set, ask user "Permission to overwrite the file y/n?". With the suggested default prompt being no, `[n]`.
        - If it is already present and the -f (--force) flag is set, overwrite the existing file without prompting the user.
        - Else, create a CSV file with the chosen name.
        - Write the contents of the Google Sheet Tab as a CSV file. (comma delimeter, double quotes used to encapsulate strings)

TODO
====

[](#todo)

- Code reuse with `AbstractCommand`

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~26 days

Recently: every ~32 days

Total

6

Last Release

2766d ago

PHP version history (2 changes)v0.1.0PHP ^7.1

v0.2.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/b3f30d378f09a6e60c2bc0344743b0a0ac47a039940ca322042d94f11016c306?d=identicon)[forikal-uk](/maintainers/forikal-uk)

---

Top Contributors

[![janklan](https://avatars.githubusercontent.com/u/5463371?v=4)](https://github.com/janklan "janklan (34 commits)")[![john-arcus](https://avatars.githubusercontent.com/u/32770045?v=4)](https://github.com/john-arcus "john-arcus (22 commits)")[![forikal-uk](https://avatars.githubusercontent.com/u/39656410?v=4)](https://github.com/forikal-uk "forikal-uk (8 commits)")[![igormukhingmailcom](https://avatars.githubusercontent.com/u/6544038?v=4)](https://github.com/igormukhingmailcom "igormukhingmailcom (5 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/forikal-uk-capture-lookups/health.svg)

```
[![Health](https://phpackages.com/badges/forikal-uk-capture-lookups/health.svg)](https://phpackages.com/packages/forikal-uk-capture-lookups)
```

###  Alternatives

[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19462.3M1.3k](/packages/drupal-core)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[chameleon-system/chameleon-base

The Chameleon System core.

1026.5k3](/packages/chameleon-system-chameleon-base)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
