PHPackages                             neighborhoods/snowflake-sql-api-component - 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. [API Development](/categories/api)
4. /
5. neighborhoods/snowflake-sql-api-component

ActiveLibrary[API Development](/categories/api)

neighborhoods/snowflake-sql-api-component
=========================================

A Client Component for Snowflake SQL API.

1.0.2(1mo ago)0162proprietaryPHPPHP ^7.3|^8

Since Mar 20Pushed 1mo agoCompare

[ Source](https://github.com/neighborhoods/SnowflakeSqlApiComponent)[ Packagist](https://packagist.org/packages/neighborhoods/snowflake-sql-api-component)[ RSS](/packages/neighborhoods-snowflake-sql-api-component/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (3)Dependencies (18)Versions (6)Used By (0)

Snowflake SQL API Component
===========================

[](#snowflake-sql-api-component)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0a418dbcb10ca882cf6cd77187534ba81f3a160db5507260f77a50c1ff94bc20/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e65696768626f72686f6f64732f736e6f77666c616b652d73716c2d6170692d636f6d706f6e656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/neighborhoods/snowflake-sql-api-component)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/f8a755da5c4877aee58c66601590c14ce118e0f0eff101834a93f3c57cd02d5b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e65696768626f72686f6f64732f736e6f77666c616b652d73716c2d6170692d636f6d706f6e656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/neighborhoods/snowflake-sql-api-component)

A Client Component for [Snowflake SQL API](https://docs.snowflake.com/en/developer-guide/sql-api/index).

Install
-------

[](#install)

Via Composer

```
$ composer require neighborhoods/snowflake-sql-api-component
```

Usage
-----

[](#usage)

This package offers two ways for interacting with the Snowflake SQL API.

- [Single Statement Client V1](#single-statement-client-v1), which is a higher level client implementation. It's much simpler to use, but does not provide access to all the features offered by the API.
- [Client V1](#client-v1), which is low level client implementation providing access to all features.

Both implementations use the same [Authentication](#authentication), which is an essential part of Client V1.

### Single Statement Client V1

[](#single-statement-client-v1)

The Snowflake SQL API has many useful features which includes.

- Submitting multiple statments at once, possibly in the same transaction.
- The statements might take a long time to execute. If the execution threshold is exceeded the API indicates that the statements are still ongoing. The Client application can check the status later on.
- The results are patritioned/paginated.

While these features are important, in practice the following is encountered:

- There is often just one statement being executed without using transactions.
- The statement is typically lightweight due to which the first page of results is returned right away.

When the above is true, the Single Statement Client V1 can be used. Single Statement Client V1 uses Client V1 under the hood, taking care of building the appropriate API request(s) and error handling.

#### Execute a statement

[](#execute-a-statement)

```
use Neighborhoods\SnowflakeSqlApiComponent\SingleStatementClientV1;

/** @var SingleStatementClientV1\ClientInterface $client */
$rows = $client->execute("SELECT 'Hello World!' as text_field, 1 as int_field");
foreach ($rows as $row) {
    foreach ($row as $columnName => $columnValue) {
        echo $columnName . ': ' . $columnValue . PHP_EOL;
    }
}
```

The `execute()` method returns all the rows from all the pages. Each row is an associative array. The keys in the row are the column names, while the values are the cell value.

The code above results in the output below. There is only one row returned.

```
TEXT_FIELD: Hello World!
INT_FIELD: 1

```

Notably all the column names are uppercased, because in Snowflake unquoted column names default to uppercase and are treated as case-insensitive.

#### Binding variables

[](#binding-variables)

It is possible to pass an array of binding variables as second argument to the `execute()` method.

```
use Neighborhoods\SnowflakeSqlApiComponent\SingleStatementClientV1;

/** @var SingleStatementClientV1\ClientInterface $client */
$rows = $client->execute("SELECT CONCAT('Hello ', ?, '!') as \"text_field\", ? as \"int_field\"", ['Again', 5]);
foreach ($rows as $row) {
    foreach ($row as $columnName => $columnValue) {
        echo $columnName . ': ' . $columnValue . PHP_EOL;
    }
}
```

The code above results in the output below.

```
text_field: Hello Again!
int_field: 5

```

#### Execute Paginated

[](#execute-paginated)

For common select queries the volume of the results isn't that big. The `execute()` method combines the data from all the pages, if multiple.

If the statement is expected to produce many pages of data raising concerns on memory consumptions the `executePaginated()` method can be used instead.

```
use Neighborhoods\SnowflakeSqlApiComponent\SingleStatementClientV1;

/** @var SingleStatementClientV1\ClientInterface $client */
$generator = $client->executePaginated("
WITH RECURSIVE NumberSequence (n, long_text_field) AS (
  SELECT 1 AS n, 'Lorem ipsum dolor sit amet' as long_text_field
  UNION ALL
  SELECT n + 1, concat(long_text_field, ', Lorem ipsum dolor sit amet') FROM NumberSequence WHERE n < 100000
)
SELECT n FROM NumberSequence ORDER BY n");

foreach ($generator as $page) {
    echo 'Page starts with ' . $page[0]['N'] . ' and ends with ' . end($page)['N'] . PHP_EOL;
}
```

The code above results in the output below.

```
Page starts with 1 and ends with 12288
Page starts with 12289 and ends with 65536
Page starts with 65537 and ends with 100000

```

#### Queries taking too long

[](#queries-taking-too-long)

If the execution of the statement takes too long, the results won't be returned right away, in which case the statement is canceled and an `OngoingException` is raised.

#### DI Paths

[](#di-paths)

To build a DI container providing a `SingleStatementClientV1\ClientInterface`, the following paths are needed

```
->addSourcePath('vendor/neighborhoods/snowflake-sql-api-component/fab')
->addSourcePath('vendor/neighborhoods/snowflake-sql-api-component/src')
->addSourcePath('vendor/neighborhoods/throwable-diagnostic-component/fab/ThrowableDiagnosticV1')
->addSourcePath('vendor/neighborhoods/throwable-diagnostic-component/src/ThrowableDiagnosticV1')
->addSourcePath('vendor/neighborhoods/throwable-diagnostic-component/fab/ThrowableDiagnosticV1Decorators/GuzzleV1')
->addSourcePath('vendor/neighborhoods/throwable-diagnostic-component/src/ThrowableDiagnosticV1Decorators/GuzzleV1')

```

#### Passing JwtTokenGenerator

[](#passing-jwttokengenerator)

The `SingleStatementClientV1\ClientV1Interace` DI service is only missing a configured `ClientV1\JwtTokenGenerator` for [authentication](#authentication).

```
use Neighborhoods\SnowflakeSqlApiComponent\SingleStatementClientV1;

/** @var SingleStatementClientV1\ClientInterface $client */
$client = $container->get(SingleStatementClientV1\ClientInterface::class);
$client->setClientV1JwtTokenGenerator($jwtTokenGenerator);
```

### Client V1

[](#client-v1)

The `Neighborhoods\SnowflakeSqlApiComponent\ClientV1` namespace contains a low level client implementation. While it allows using all the features of the Snowflake SQL API, using it is challenging. Often the simpler [Single Statement Client V1](#single-statement-client-v1) can be used instead. More information about the Client V1 is available [here](./docs/ClientV1.md).

### Authentication

[](#authentication)

At the moment only [key-pair authentication](https://docs.snowflake.com/en/developer-guide/sql-api/authenticating#label-sql-api-authenticating-key-pair) is supported.

Key-pair authentication is handled by the `ClientV1\JwtTokenGenerator`. Configure the `JwtTokenGenerator` by setting the Account, User and Private Key as shown below.

```
use Neighborhoods\SnowflakeSqlApiComponent\ClientV1;

$jwtTokenGenerator = (new ClientV1\JwtTokenGenerator())
    ->setAccount('snowflake_account')
    ->setUser('snowflake_user')
    ->setPrivateKey(file_get_contents('~/path/snowflake_private_key.pem'));
```

This can also be done by defining a Symfony DI service using environment variables.

```
#YourProjectPath/src/Vendor/SnowflakeSqlApiComponent/ClientV1/JwtTokenGenerator.service.yml
parameters:
  Neighborhoods\SnowflakeSqlApiComponent\ClientV1\JwtTokenGeneratorInterface.account: '%env(SNOWFLAKE_ACCOUNT)%'
  Neighborhoods\SnowflakeSqlApiComponent\ClientV1\JwtTokenGeneratorInterface.user: '%env(SNOWFLAKE_USER)%'
  Neighborhoods\SnowflakeSqlApiComponent\ClientV1\JwtTokenGeneratorInterface.privateKey: '%env(SNOWFLAKE_PRIVATE_KEY)%'
services:
  Neighborhoods\SnowflakeSqlApiComponent\ClientV1\JwtTokenGeneratorInterface:
    class: Neighborhoods\SnowflakeSqlApiComponent\ClientV1\JwtTokenGenerator
    public: false
    shared: true
    calls:
      - [setAccount, ['%Neighborhoods\SnowflakeSqlApiComponent\ClientV1\JwtTokenGeneratorInterface.account%']]
      - [setUser, ['%Neighborhoods\SnowflakeSqlApiComponent\ClientV1\JwtTokenGeneratorInterface.user%']]
      - [setPrivateKey, ['%Neighborhoods\SnowflakeSqlApiComponent\ClientV1\JwtTokenGeneratorInterface.privateKey%']]
```

Test script
-----------

[](#test-script)

The `vendor/bin/single_statement_client_v1_connection_test` script can be run to build a container providing a `SingleStatementClientV1\ClientInterface` instance. The test script uses [DICBC](https://github.com/neighborhoods/DependencyInjectionContainerBuilderComponent), which isn't a direct dependency of this package. You might need to add it to your development environment.

The `SELECT 'Hello World'` query is executed to test the Snowflake connection. If the credentials are valid, the result will be printed. Run the script for more details.

Examples
--------

[](#examples)

Application examples are available in the [Fitness](https://github.com/neighborhoods/SnowflakeSqlApiComponentFitness) project.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance92

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

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

Total

3

Last Release

39d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8584765?v=4)[neighborhoods.com](/maintainers/neighborhoods)[@neighborhoods](https://github.com/neighborhoods)

---

Top Contributors

[![Firtzberg](https://avatars.githubusercontent.com/u/8490119?v=4)](https://github.com/Firtzberg "Firtzberg (9 commits)")

---

Tags

clientsdksnowflakesnowflake-sqlsnowflake-apisnowflake-sql-api

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/neighborhoods-snowflake-sql-api-component/health.svg)

```
[![Health](https://phpackages.com/badges/neighborhoods-snowflake-sql-api-component/health.svg)](https://phpackages.com/packages/neighborhoods-snowflake-sql-api-component)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.2k532.1M2.5k](/packages/aws-aws-sdk-php)[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k8.8M83](/packages/openai-php-laravel)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)[resend/resend-php

Resend PHP library.

596.2M35](/packages/resend-resend-php)[mozex/anthropic-laravel

Laravel integration for the Anthropic API: facade, config publishing, install command, testing fakes, messages, streaming, tool use, thinking, and batches.

72287.1k1](/packages/mozex-anthropic-laravel)[crowdin/crowdin-api-client

PHP client library for Crowdin API v2

611.6M5](/packages/crowdin-crowdin-api-client)

PHPackages © 2026

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