PHPackages                             namshi/gvalue - 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. namshi/gvalue

ActiveLibrary

namshi/gvalue
=============

A library to parse Google Docs and convert them into a key-value array

1.0.0(12y ago)525.1k11MITPHP

Since Jan 10Pushed 12y ago7 watchersCompare

[ Source](https://github.com/namshi/gvalue)[ Packagist](https://packagist.org/packages/namshi/gvalue)[ RSS](/packages/namshi-gvalue/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (2)Versions (3)Used By (1)

Gvalue: convert Google Docs to a key-value array
================================================

[](#gvalue-convert-google-docs-to-a-key-value-array)

[![Build Status](https://camo.githubusercontent.com/249679d4d4ff52a33dd14ee2299705954252beef712b189c279c128950e64746/68747470733a2f2f7472617669732d63692e6f72672f6e616d7368692f6776616c75652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/namshi/gvalue)

The aim of this library is to be able to parse a Google Spreadsheet as a simple key-value, so that you can use it to configure your applications.

Isn't this twisted?
-------------------

[](#isnt-this-twisted)

> With great power comes great responsibility.

We want to be able to change the configuration of our apps in the easiest way, so we thought we should have an easily accessible key-value storage where we would put those config values that will be used by the apps: for example, products per page, cache lifetime, and so on and so forth. We eventually figured out that Redis would be a very good candidate for storing our configuration.

The problem comes when you think of **how** you would update that configuration values:

- ssh into your server
- log into redis
- change a value

Even though this might sound simple to you should consider that it might be a **slow and repetitive task** and that **you need to be a developer / sysadmin** for doing it.

This means that if your PM wants to change the cache lifetime of your homepage, the number of articles you can show per page, he has to ask you. Call you. Wake you up in the night. Follow you. Stalk you.

**You're doomed**.

Or are you? By storing your config into a google doc you can simply give access to it to anyone who's responsible enough to understand what `products per page: 30` means! They can update the doc, invoke a URL which will use this library to convert it to a key-value array and store it in redis and you can happily delegate tasks and require no more deployments for a change in your configuration!

Usage
-----

[](#usage)

Create a Google Spreadsheet organized in two columns: the first one will represent the configuration keys while the second one the values:

[![a simple google doc](https://github.com/namshi/gvalue/raw/master/bin/images/doc.png?raw=true)](https://github.com/namshi/gvalue/blob/master/bin/images/doc.png?raw=true)

At this point you will have to publish the Google Doc to the web so that it will become available at a (sort of) public URL:

[![publish google doc](https://github.com/namshi/gvalue/raw/master/bin/images/doc-publish.png?raw=true)](https://github.com/namshi/gvalue/blob/master/bin/images/doc-publish.png?raw=true)

Then you simply have to run the following code and get the key-value configuration out of your google doc:

```
