- Clone this project
- Run
composer install
- test the console app:
php bin/gsheet-to-xml.php --help
Note Make sure you're using at least PHP 7.1
php bin/gsheet-to-xml.php {URL} [--credentials=client_secret.json] [--recursive]
{URL}
should be either Drive or Sheets URL in one of following formats
- https://drive.google.com/drive/folders/xxxxxxxxxx-xxxxxxxxx-xxxxxxxxxxxx
- https://docs.google.com/spreadsheets/d/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/edit
-c, --credentials
is optional parameter that specifies path to the credentials file with Google secret. Path
must be relative to the directory you're calling the script from.
-r, --recursive
if the Google Drive entity is a Google Drive folder, this option specifies whether or not to recurse
through sub-directories to find sheets.
- Empty rows are skipped without notice.
- Files ending with _ (underscore) are ignored (e.g. foo_.xslx, foo_)
- Tabs ending with _ (underscore) are ignored
- When parsing folders, for every spreadsheet found new
<Product><Inventory>
XML element is created withsrc-sheet-url
attribute containing the spreadsheet ID.
If the package is being edited in standalone context:
Run ./vendor/bin/phpunit
to execute test suite
If the package is being edited in context of some other parent project you could run phpunit from the root directory and point to this package's tests folder explicitly:
$ pwd
/some/parent/project/root/folder
$ ./vendor/phpunit/phpunit/phpunit vendor/xmlsquad/gsheet-to-xml/tests/
- https://www.fillup.io/post/read-and-write-google-sheets-from-php/
- https://developers.google.com/sheets/api/samples/reading
- https://stackoverflow.com/a/16840612
- https://developers.google.com/sheets/api/guides/concepts
- You have to enable both Sheets and Drive API
- You have to share files/folders with email in credentials JSON file