PHPackages                             chancegarcia/php-box-sdk - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. chancegarcia/php-box-sdk

ActiveLibrary[HTTP &amp; Networking](/categories/http)

chancegarcia/php-box-sdk
========================

PHP SDK and API client for the Box API v2024.0, supporting OAuth2 and JWT/S2S authentication, file and folder operations, uploads, webhook signature verification, typed models, and PSR-3 logging.

v1.0.3(3w ago)873Apache-2.0PHPPHP &gt;=8.4CI passing

Since Jan 20Pushed 3w ago3 watchersCompare

[ Source](https://github.com/chancegarcia/php-box-sdk)[ Packagist](https://packagist.org/packages/chancegarcia/php-box-sdk)[ Docs](https://github.com/chancegarcia/php-box-sdk)[ RSS](/packages/chancegarcia-php-box-sdk/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (14)Versions (30)Used By (0)

Box PHP SDK
===========

[](#box-php-sdk)

[![CI](https://github.com/chancegarcia/php-box-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/chancegarcia/php-box-sdk/actions/workflows/ci.yml)[![Latest Stable Version](https://camo.githubusercontent.com/39b860130bdb95882427074be84a166d922107de39c91d46d8974805fcf315df/68747470733a2f2f736869656c64732e696f2f7061636b61676973742f762f6368616e63656761726369612f7068702d626f782d73646b3f6c6162656c3d737461626c65)](https://packagist.org/packages/chancegarcia/php-box-sdk)[![PHP Version Require](https://camo.githubusercontent.com/b24d036dcf006fdb58b7f04cb1a08119ac801cea8a33721bfa2e309a47c4c934/68747470733a2f2f736869656c64732e696f2f7061636b61676973742f7068702d762f6368616e63656761726369612f7068702d626f782d73646b)](https://packagist.org/packages/chancegarcia/php-box-sdk)[![License](https://camo.githubusercontent.com/d3c637de5e5d9bb81803df124a97d1778c19736e632e29a4dc46b90f00e31521/68747470733a2f2f736869656c64732e696f2f7061636b61676973742f6c2f6368616e63656761726369612f7068702d626f782d73646b)](https://packagist.org/packages/chancegarcia/php-box-sdk)[![Total Downloads](https://camo.githubusercontent.com/dd64ba37eaa3898913919ab23fe9a51be9f54fee39b4e3543380e080c972c231/68747470733a2f2f736869656c64732e696f2f7061636b61676973742f64742f6368616e63656761726369612f7068702d626f782d73646b)](https://packagist.org/packages/chancegarcia/php-box-sdk)

A modern PHP SDK for interacting with the [Box.com API](https://developer.box.com/).

**Status:** v1.0.0 released.

This library is designed as a boundary layer for Box API access, suitable for standalone use or integration into frameworks like Symfony.

Requirements
------------

[](#requirements)

- PHP 8.4 or higher
- `ext-fileinfo`

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

[](#installation)

```
composer require chancegarcia/php-box-sdk
```

Quickstart
----------

[](#quickstart)

### OAuth2 Workflow

[](#oauth2-workflow)

The recommended setup uses `BoxClientFactory` with an `EnvConfigProvider`, which reads credentials from environment variables (`BOX_OAUTH_CLIENT_ID`, `BOX_OAUTH_CLIENT_SECRET`, etc.):

```
use Box\Service\BoxClientFactory;
use Box\Service\EnvConfigProvider;

$factory = new BoxClientFactory(new EnvConfigProvider());
$client  = $factory->createClient();
```

Generate the authorization URL and redirect the user:

```
$authUrl = $client->buildAuthorizationUrl();
// Redirect user to $authUrl
```

After the user authorizes and is redirected back with a `code`, exchange it for a token:

```
$client->setAuthorizationCode($_GET['code']);
$token = $client->exchangeAuthorizationCodeForToken();
```

### JWT / Server-to-Server

[](#jwt--server-to-server)

For server-to-server integrations (no browser redirect needed), set `BOX_AUTH_MODE=jwt` and the `BOX_JWT_*` environment variables, then:

```
use Box\Service\BoxClientFactory;
use Box\Service\EnvConfigProvider;

$configProvider = new EnvConfigProvider();
$factory        = new BoxClientFactory($configProvider);
$client         = $factory->createClientForCurrentMode(); // JWT client when BOX_AUTH_MODE=jwt
```

See the [Programmatic Usage Guide](docs/user/programmatic-usage.md) for enterprise and app-user token exchange examples.

### File and Folder Operations

[](#file-and-folder-operations)

```
use Box\Http\FileStream;

$client->setToken($token);

// Upload a local file
$result = $client->uploadFileToBox('/path/to/file.txt', '12345');

// Upload via stream (no local file needed)
$stream = FileStream::fromString('Hello World', 'hello.txt');
$result = $client->uploadFileToBox($stream, '0'); // '0' is the root folder ID

// Get a folder
$folder = $client->getFolder('12345');
```

Advanced Documentation
----------------------

[](#advanced-documentation)

For in-depth architectural guidance, library integration patterns, and advanced usage:

- [Programmatic Usage Guide](docs/user/programmatic-usage.md) — OAuth2, JWT/S2S, token storage, error handling, file streaming
- [CLI Test Harness Guide](docs/user/cli-test-harness.md) — `bin/box-sdk` commands for manual verification
- [v1.0 Migration Guide](docs/migration/upgrading-0.11-to-1.0.md) — upgrading from v0.11

Development and Quality Checks
------------------------------

[](#development-and-quality-checks)

```
composer review    # Run all checks (recommended before pushing)
composer test      # PHPUnit
composer analyse   # PHPStan
composer cs:check  # PHP_CodeSniffer
composer cs:fix    # Fix code style automatically
composer lint      # PHP syntax check
```

---

**See also:**

- [Changelog](CHANGELOG.md)
- [Documentation Index](docs/README.md)

License
-------

[](#license)

Apache 2.0 License. See [LICENSE](LICENSE) for details.

This project was previously distributed under the MIT License. As of `v1.0.0` it is relicensed under Apache 2.0.

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance95

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity91

Battle-tested with a long release history

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

Recently: every ~4 days

Total

25

Last Release

22d ago

Major Versions

v0.11.3 → v1.0.02026-05-18

PHP version history (4 changes)0.3.1PHP &gt;=5.6.10

0.6.0PHP &gt;=7.1

0.9.0PHP &gt;=8.2

0.11.0PHP &gt;=8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/6da225b703a123deac986a29c01b0dbda6d27d036c17ae04cbcffbe0fc2a3294?d=identicon)[chance](/maintainers/chance)

---

Top Contributors

[![chancegarcia](https://avatars.githubusercontent.com/u/348263?v=4)](https://github.com/chancegarcia "chancegarcia (522 commits)")

---

Tags

psr-3jwtsdkGuzzleoauth2webhookapi clientphp-sdkboxfile-uploadcloud-storagefile storagebox-sdkbox-apibox-api-v2024box-v2box-platform

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/chancegarcia-php-box-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/chancegarcia-php-box-sdk/health.svg)](https://phpackages.com/packages/chancegarcia-php-box-sdk)
```

###  Alternatives

[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M506](/packages/shopware-core)[aws/aws-sdk-php

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

6.3k532.1M2.5k](/packages/aws-aws-sdk-php)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k11](/packages/tempest-framework)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.8M710](/packages/sylius-sylius)

PHPackages © 2026

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