PHPackages                             keboola/staging-provider - 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. keboola/staging-provider

ActiveLibrary

keboola/staging-provider
========================

12.2.0(10mo ago)129.9k↓35.4%3MITPHPPHP &gt;=8.2

Since Apr 12Pushed 2mo ago12 watchersCompare

[ Source](https://github.com/keboola/staging-provider)[ Packagist](https://packagist.org/packages/keboola/staging-provider)[ RSS](/packages/keboola-staging-provider/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (9)Versions (62)Used By (3)

Staging Provider
================

[](#staging-provider)

[![Build Status](https://camo.githubusercontent.com/53eff7979493f5f1c606c86d32ddd90b0e72cc61e8bd623e25316728bd536263/68747470733a2f2f6465762e617a7572652e636f6d2f6b65626f6f6c612d6465762f776f6b73706163652d70726f76696465722f5f617069732f6275696c642f7374617475732f6b65626f6f6c612e73746167696e672d70726f76696465723f6272616e63684e616d653d6d61696e)](https://dev.azure.com/keboola-dev/wokspace-provider/_build/latest?definitionId=69&branchName=main)

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

[](#installation)

`composer require keboola/staging-provider`

Usage
-----

[](#usage)

The staging provider package helps you to properly configure input/output staging factory for various environments.

Typical use-case can be set up a `Reader` instance to access some data:

```
use Keboola\InputMapping\Reader;
use Keboola\InputMapping\Staging\StrategyFactory as InputStrategyFactory;
use Keboola\StagingProvider\InputProviderInitializer;
use Keboola\StagingProvider\Workspace\ExistingWorkspaceProvider;
use Keboola\StorageApi\Client;
use Keboola\StorageApi\Workspaces;
use Keboola\StorageApiBranch\ClientWrapper;
use Psr\Log\NullLogger;

$storageApiClient = new Client(...);
$storageApiClientWrapper = new ClientWrapper($storageApiClient, ...);
$logger = new NullLogger();

$strategyFactory = new InputStrategyFactory($storageApiClientWrapper, $logger, 'json');
$tokenInfo = $storageApiClient->verifyToken();
$dataDir = '/data';

$workspaceProvider = new ExistingWorkspaceProvider(
    new Workspaces($storageApiClient),
    'my-workspace', // workspace ID
    new Credentials\ExistingCredentialsProvider(
        new Configuration\WorkspaceCredentials([
            'password' => 'abcd1234' // workspace password
        ]),
    ),
);

$providerInitializer = new InputProviderInitializer($strategyFactory, $workspaceProvider, $dataDir);
$providerInitializer->initializeProviders(
    InputStrategyFactory::WORKSPACE_SNOWFLAKE,
    $tokenInfo
);

// now the $strategyFactory is ready to be used
$reader = new Reader($strategyFactory);
```

We start by creating a `StrategyFactory` needed by the reader. The strategy itself has no knowledge of which storage should be used with each staging type. This is what provider initializer does - configure the `StrategyFactory` for a specific type of staging.

To create a provider initializer, we pass it:

- the `StrategyFactory` to initialize
- a workspace provider, used to access workspace information for workspace staging
    - `ExistingWorkspaceProvider` in case we want to re-use existing workspace
    - `NewWorkspaceProvider` in case we want a new workspace to be created (based on a component configuration)
- a data directory path used for local staging

Then we call `initializeProviders` method to configure the `StrategyFactory` for specific staging type. It's up to the caller to know, which staging type to configure:

- when working with components, each component has staging type defined in its configuration
- sandbox has the type deduced from its workspace
- etc.

The example above presents usage of `InputProviderInitializer` for configuration of input mapping `StrategyFactory` for a `Reader`. Similarly, we can use `OutputProviderInitializer` to configure output mapping `StrategyFactory` for a `Writer`.

Internals
---------

[](#internals)

The main objective of the library is to configure `StrategyFactory` so it knows which staging provider to use with each kind of storage.

### Staging

[](#staging)

Generally, there are two kinds of staging:

- local staging - used to store data locally on filesystem, represented by `LocalStaging` class
- workspace staging - used to store data in a workspace, represented by `WorkspaceStagingInterface`

### Provider (staging provider)

[](#provider-staging-provider)

The `StrategyFactory` does not use a staging directly but rather through a provider (`ProviderInterface`) so there is a provider implementation for each kind:

- `LocalStagingProvider` - for local filesystem staging
- `WorkspaceProviderInterface` - for Connection workspace staging

The main reason the `StrategyFactory` does not use the staging directly is to achieve lazy initialization of the staging - provider instance is created during bootstrap, but the staging instance is only created when really used.

### Workspace provider factory

[](#workspace-provider-factory)

Local staging is pretty simple. It contains just the path to the data directory, provided by the caller. On the other hand, things get a bit more complicated with workspace staging as the provider may represent an already existing workspace or a configuration for creating a new workspace. To achieve this, caller must provide a `WorkspaceProviderInterface`. Currently, there are 2 implementations:

- `NewWorkspaceProvider` which creates a provider that creates a new workspace based on a component configuration
- `ExistingWorkspaceProvider` which creates a provider working with an existing workspace

When using `ExistingWorkspaceProvider`, a developer is responsible for providing workspace credentials. Depending on the situation, the following options are available:

- `ExistingCredentialsProvider` for situation when we know the exact workspace credentials. For example, when working with a workspace for which the end user provides credentials, like SQL sandbox. Credentials are in the form of a free array, and it's the caller's responsibility to provide correct credentials properties (password, private key, etc.).
- `ResetCredentialsProvider` for situation nobody else accesses the workspace, and we can safely generate new credentials. This is typical when working with a staging workspace, which is accessed only through code (nobody has stored the credentials anywhere).
- `NoCredentialsProvider` for situations when we need to just work with the workspace indirectly (through Connection API) and don't need credentials. When something tries to access the credentials, the provider throws an exception.

Development
-----------

[](#development)

First start with creating `.env` file from `.env.dist`.

```
cp .env.dist .env
# edit .env to set variable values
```

To run tests, there is a separate service for each PHP major version (5.6 to 7.4). For example, to run tests against PHP 5.6, run following:

```
docker compose run --rm tests56
```

To develop locally, use `dev` service. Following will install Composer dependencies:

```
docker compose run --rm dev composer install
```

License
-------

[](#license)

MIT licensed, see [LICENSE](./LICENSE) file.

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance71

Regular maintenance activity

Popularity29

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity79

Established project with proven stability

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

Recently: every ~13 days

Total

40

Last Release

321d ago

Major Versions

7.1.0 → 8.0.02024-09-16

8.1.0 → 9.0.02024-11-21

9.1.1 → 10.0.02025-05-07

10.0.1 → 11.0.02025-05-15

11.0.0 → 12.0.02025-05-26

PHP version history (4 changes)1.0.0PHP &gt;=5.6

3.0.0PHP &gt;=7.4

6.0.0PHP &gt;=8.1

7.1.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/101dbf2551a0709ddab522f97669f13a2c4cc2d0a1e8d009f3af6ba80accb1a9?d=identicon)[Keboola](/maintainers/Keboola)

---

Top Contributors

[![pepamartinec](https://avatars.githubusercontent.com/u/271753?v=4)](https://github.com/pepamartinec "pepamartinec (88 commits)")[![odinuv](https://avatars.githubusercontent.com/u/4319320?v=4)](https://github.com/odinuv "odinuv (52 commits)")[![ErikZigo](https://avatars.githubusercontent.com/u/1726727?v=4)](https://github.com/ErikZigo "ErikZigo (38 commits)")[![ondrajodas](https://avatars.githubusercontent.com/u/12143866?v=4)](https://github.com/ondrajodas "ondrajodas (6 commits)")[![pivnicek](https://avatars.githubusercontent.com/u/569139?v=4)](https://github.com/pivnicek "pivnicek (3 commits)")[![AdamVyborny](https://avatars.githubusercontent.com/u/27994036?v=4)](https://github.com/AdamVyborny "AdamVyborny (2 commits)")[![MiroCillik](https://avatars.githubusercontent.com/u/1488015?v=4)](https://github.com/MiroCillik "MiroCillik (1 commits)")[![ujovlado](https://avatars.githubusercontent.com/u/419849?v=4)](https://github.com/ujovlado "ujovlado (1 commits)")

---

Tags

keboolastaging-provider

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/keboola-staging-provider/health.svg)

```
[![Health](https://phpackages.com/badges/keboola-staging-provider/health.svg)](https://phpackages.com/packages/keboola-staging-provider)
```

PHPackages © 2026

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