PHPackages                             schenke-io/laravel-sheet-base - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. schenke-io/laravel-sheet-base

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

schenke-io/laravel-sheet-base
=============================

Use Google Sheet files as team-editor for Laravel translations and as data source for Laravel models using Laravel Sushi.

v1.19.0(1y ago)0105MITPHPPHP ^8.2CI passing

Since Dec 9Pushed 1y ago1 watchersCompare

[ Source](https://github.com/schenke-io/laravel-sheet-base)[ Packagist](https://packagist.org/packages/schenke-io/laravel-sheet-base)[ Docs](https://github.com/schenke-io/laravel-sheet-base)[ RSS](/packages/schenke-io-laravel-sheet-base/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (16)Versions (56)Used By (0)

Laravel Sheet Base
==================

[](#laravel-sheet-base)

[![Latest Version on Packagist](https://camo.githubusercontent.com/958210b335f650ab4dc6aa1d7a21466d0b58d1ffc99a6ee5407d5dc112506030/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736368656e6b652d696f2f6c61726176656c2d73686565742d626173652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/schenke-io/laravel-sheet-base)[![GitHub Tests Action Status](https://camo.githubusercontent.com/99185d5bbbaf97a3a42c620862172c8f7ba42b8f258c61c04d8bc830056d2d3b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736368656e6b652d696f2f6c61726176656c2d73686565742d626173652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d72756e2d7465737473267374796c653d666c61742d737175617265)](https://github.com/schenke-io/laravel-sheet-base/actions?query=workflow%3Atests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/dbf3f3b2610ae692d6bb8d51fbd3569b9b9b2e1611b8e34b435c4acffffb77a7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736368656e6b652d696f2f6c61726176656c2d73686565742d626173652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/schenke-io/laravel-sheet-base)[![Coverage](/.github/coverage.svg)](/.github/coverage.svg)[![PHPStan](/.github/phpstan.svg)](/.github/phpstan.svg)

The **Laravel Sheet Base** package simplifies data processing by offering a collection of classes specifically tailored for building efficient data conversion pipelines. These pipelines are well-suited for scenarios where data modifications occur infrequently.

Here are some ideal use cases for this package:

- **Manually edited data sources:** When most of your data originates from manual edits by specialists.
- **Infrequent data changes:** When your data remains relatively stable over time.
- **Command line efficiency:** When utilizing a developer console command proves more efficient than a web form for data processing tasks.

These pipelines involve **reading data** from **endpoints**on one end and **processing &amp; storing** it using a **writer**on the other. Each pipeline uses a **schema** to define the **table format** for the writer.

The Laravel Sheet Base package simplifies managing and transforming data in your Laravel applications. It offers several useful features:

- **Work with various data formats:** Import data from CSV files and export it to JSON, YAML, or Neon formats.
- **Extract translations:** Easily gather translations from different sources and generate language files.
- **Combine data sources:** Merge data from multiple sources into a single, targeted output.
- **Transform and write data:** Read data, perform calculations, and write the resulting transformed data.
- **Generate files:** Create files for seeding, backups, configuration, or Laravel Sushi integration.

The package utilizes a flexible and extensible pipeline architecture, making data management tasks efficient and straightforward.

- [Laravel Sheet Base](#laravel-sheet-base)
    - [Supported Readers](#supported-readers)
    - [Supported Writers](#supported-writers)
    - [Schema building blocks](#schema-building-blocks)
    - [Pipeline Pumping Process](#pipeline-pumping-process)
    - [Installation](#installation)
    - [Configuration](#configuration)
        - [Filesystem](#filesystem)
        - [Pipelines](#pipelines)
        - [Schema](#schema)
        - [Schema columns](#schema-columns)
        - [Endpoints](#endpoints)
            - [Accessing Files](#accessing-files)
                - [Extending Existing Classes](#extending-existing-classes)
                - [Using Filename Extensions](#using-filename-extensions)
                - [Extension and endpoints](#extension-and-endpoints)
            - [Endpoints as array](#endpoints-as-array)
            - [Endpoint to write language files](#endpoint-to-write-language-files)
            - [Endpoint to read Google Sheets](#endpoint-to-read-google-sheets)
    - [Verify the configuration](#verify-the-configuration)
    - [Pumping](#pumping)
    - [License](#license)

Supported Readers
-----------------

[](#supported-readers)

- File readers
- Array readers
- Collection readers
- Eloquent model readers
- Cloud file readers
- Google Sheets readers

Supported Writers
-----------------

[](#supported-writers)

The package includes versatile writers capable of handling various file formats:

- typical data file formats (JSON, Neon, YAML)
- PHP (config) files (suitable for tests, configuration files, or Laravel Sushi)
- Laravel language php-files

Additionally, all written files that support comments include remarks about the reference file, discouraging direct editing.

Schema building blocks
----------------------

[](#schema-building-blocks)

Here are the three basic building blocks for creating a schema:

- **ID-based tables:** These tables have many columns and a single ID field in the first column.
- **Language files:** These files use a key in dot notation and have separate columns for each language code.
- **Simple sources:** These are single-column sources that lack a key column, the ID is generated automatically.

Pipeline Pumping Process
------------------------

[](#pipeline-pumping-process)

Here's the breakdown of how a pipeline pumps data:

- **Read data:** Each line of data is read into a "dataRow".
- **Assign key:** The dataRow gets its key either from an "ID" column or a numeric sequence.
- **New key:** If the key is new, a new "target dataRow" is created for that ID, with all its columns filled with null values.
- **Fill data:** For each key required by the schema, its value is searched for in the source data. If found, it's added to the corresponding column of the target dataRow.
- **Repeat:** This process repeats for each source dataRow, even if the same ID appears multiple times.
- **Write output:** Once all sources are read, the entire dataset is written from memory to a target, using the appropriate format function for each column.

**Pipeline execution:**

- Pipelines are executed in the alphabetic order of the pipeline names.
- Important points:
    - **No warning for duplicate IDs:** Sources can have duplicate IDs, but the final result only allows unique IDs.
    - **Optional data in sources:** Sources might not have all the data defined in the Schema.
    - **Pipelines can be chained:** One pipeline's output can be another's input.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require schenke-io/laravel-sheet-base
```

You can install the config file with:

```
php artisan sheet-base:install
```

Configuration
-------------

[](#configuration)

### Filesystem

[](#filesystem)

Configure the default disk in `config/filesystems.php`. Define a new disk `sheet-base` and specify its location. This will become the default place for files to be read and write.

### Pipelines

[](#pipelines)

Configure the pipelines in `config/sheet-base.php`. Under the primary key `pipelines` add names for each pipeline and define these 3 keys:

keypurposetypesourceswhere does the data comes fromarray of strings of classes or filenamesschemaschema of columns in output tableclass nametargetwhere does the data goes tostring of class or filenamefilterlist of ids which the pipeline should allow to passstring of class or filenamesyncsyncs data back to Google Sheetsboolean true / false### Schema

[](#schema)

Each pipeline has a Schema, which defines the columns of the written file. Create a schema by:

- **Inheriting:** Extend the `SheetBaseSchema` class.
- **Defining columns:** Override the `define()` method.
- **Adding columns:** Use one of the `$this->add*` methods within `define()` to list columns with unique names.

Here a simple example of a Schema class:

```
use SchenkeIo\LaravelSheetBase\Elements\SheetBaseSchema;

class MySchema extends SheetBaseSchema
{
    public function define(): void
    {
        $this->addId();
        $this->addString('name');
    }
}
```

### Schema columns

[](#schema-columns)

The following columns are possible:

methoddefinitioncan be nullis IDaddIdnumeric or string idyesyesaddDottext id with dots like 'alpha.beta.gamma'yesyesaddClosureallows for custom formatting function using column name and data row as inputyesnoaddUnsigned-yesnoaddUnsignedNotNull-nonoaddFloat-yesnoaddBool-nonoaddString-nonoaddLanguagevalid language code as nameyesnoaddNullString-yesnoaddDateTime-yesnoFor the two possible ID columns `addId` and `addDot` the following applies:

- must be only one ID column
- ID column must be the first column
- empty ID values are skipped
- if ID value repeats, its overwrite existing data - this allows to read from one file and add from another

Here an example of the addClosure method:

```
class MySchema extends SheetBaseSchema
{
    public function define(): void
    {
        $concat = function ($key, $row) {
            return ($row[$key] ?? '?').' '.$row['c'];
        };
        $this->addId();
        $this->addString('name');
        $this->addClosure('name2', $concat);
    }
}
```

### Endpoints

[](#endpoints)

A pipeline defines data flow between two designated points, called **endpoints**. You can define these endpoints in many ways.

#### Accessing Files

[](#accessing-files)

There are two ways to access files:

##### Extending Existing Classes

[](#extending-existing-classes)

Create a class that inherits from one of the provided endpoint classes. Each extended class must define in `$path` a path to the file. The used disk can be overwritten in `$disk` as well.

##### Using Filename Extensions

[](#using-filename-extensions)

Define a file with a specific extension, associated with the desired endpoint behavior. The file is located at the `sheet-base` $disk.

```
// config/sheet-base.php
return [
    'pipelines' => [
        'sources' => [
            'directory/data.neon',
            MyEndpoints\MyData:class
        ],
        .....
    ]
];
```

and the class for it:

```
// App\MyEndPoints\MyData
class MyData  extends EndpointWriteNeon
{
    public string $path = 'directory/data2.neon';
}
```

##### Extension and endpoints

[](#extension-and-endpoints)

extensiondocumentationreaderwritercsvcomma seperated valuesEndpointReadCsvEndpointWriteCsvjsonJavaScript Object Notation-EndpointWriteJsonneonNette Object NotationEndpointReadNeonEndpointWriteNeonphpPHP config file-EndpointWritePhppsvpipe seperated valuesEndpointReadPsvEndpointWritePsvtsvtab seperated valuesEndpointReadTsvEndpointWriteTsvtxttext files with just keys one per lineEndpointReadTxtEndpointWriteTxtyamlYAML config fileEndpointReadYamlEndpointWriteYamlymlYAML config fileEndpointReadYmlEndpointWriteYml#### Endpoints as array

[](#endpoints-as-array)

The array endpoints, `EndpointReadArray` and `EndpointWriteArray`, allow for programmatic access to other data, such as Eloquent models, APIs, or special data formats.

```
// App\MyEndpoints\PhpRead
class PhpRead extends EndpointReadArray{
    public function getArray(): array
    {
        // do magic
        return [
            1 => ['a' => 1, 'b' => 2],
            2 => ['a' => 4, 'b' => 5],
        ];
    }
}

// App\MyEndpoints\PhpWrite
class PhpWrite extends EndpointWriteArray{
    public function releasePipeline(PipelineData $pipelineData, string $writingClass): void
    {
        $this->arrayData = $pipelineData->toArray();
        # do magic with $this->arrayData
    }
}
```

#### Endpoint to write language files

[](#endpoint-to-write-language-files)

One pipeline can be used to write language php files. You need a special schema and target file.

```
// App\MyEndpoints\LanguageSchema
class LanguageSchema extends SheetBaseSchema
{
    protected function define(): void
    {
        $this->addDot('key');  // must be first, name can be different
        $this->addLanguage('de');  // only language codes as column names
        $this->addLanguage('en');
    }
}

// App\MyEndpoints\LanguageTarget
class LanguageTarget extends EndpointWriteLang
{
    // were to write the language files
    public string $root = '/';
    // which first parts of the dot-keys should result in files
    public array $fileBases = ['home'];
}
```

#### Endpoint to read Google Sheets

[](#endpoint-to-read-google-sheets)

First get a service account in the Google api console and download the json file. Then add the key `GOOGLE_APPLICATION_CREDENTIALS` to the `.env` file and fill the path to this file.

```
GOOGLE_APPLICATION_CREDENTIALS=directory/google/file.json
```

Create an empty Google sheets document and share it with the email from the service account.

There are two ways to configure the spreadsheet ID used by this plugin:

- directly in your EndpointClass
- in the config file (recommended for clarity and multiple files)

In both cases you fill the worksheet name in `$sheetName` and get than the URL of the Google sheet. The spreadsheet ID is the part of the URL after `/d/` and before `/edit`. For example, in the URL `https://docs.google.com/spreadsheets/d/123ABC-xyz123/edit`, the spreadsheet ID is 123ABC-xyz123.

In `$spreadsheetId` you enter either the ID itself or the name of the key in `config/sheet-base.php` as shown below.

```
class GoogleSheetLang extends EndpointReadGoogleSheet
{
    public string $spreadsheetId = '1ttfjdfdjfdfjdfdjfdfdkfdfdQkGDE';
    // or: public string $spreadsheetId = 'File-Main';
    public string $sheetName = 'Sheet1';
}

// in config/sheet-base.php

    'pipelines' => [
    .....
    ],
    'spreadsheets' => [
        'File-Main' => '1ttfjdfdjfdfjdfdjfdfdkfdfdQkGDE'
    ]

```

The first row in the spreadsheet must contain the column names, as specified in the pipeline schema. The table width is determined by the number of columns with header values. Additional headers to the right are ignored. Data reading stops when the first column is empty, and subsequent rows are discarded.

Verify the configuration
------------------------

[](#verify-the-configuration)

You can check the configuration after any edit with:

```
php artisan sheet-base:check
```

Pumping
-------

[](#pumping)

You can pump data through the pipelines with this command:

```
php artisan sheet-base:pump
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance48

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~9 days

Recently: every ~32 days

Total

55

Last Release

380d ago

PHP version history (2 changes)v1.0.0PHP ^8.1

v1.11.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/cf5dcac54b57dafc55c594db6ba9cb3a9a27b808f77e5cc3cda6071f56f5ad9e?d=identicon)[schenke-io](/maintainers/schenke-io)

---

Top Contributors

[![schenke-io](https://avatars.githubusercontent.com/u/111449674?v=4)](https://github.com/schenke-io "schenke-io (63 commits)")

---

Tags

laravelschenke-iolaravel-sheet-base

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/schenke-io-laravel-sheet-base/health.svg)

```
[![Health](https://phpackages.com/badges/schenke-io-laravel-sheet-base/health.svg)](https://phpackages.com/packages/schenke-io-laravel-sheet-base)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[tarfin-labs/event-machine

Event-driven state machines for Laravel with event sourcing, type-safe context, and full audit trail.

188.5k](/packages/tarfin-labs-event-machine)

PHPackages © 2026

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