PHPackages                             dmstr/php-bc4-client - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. dmstr/php-bc4-client

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

dmstr/php-bc4-client
====================

Modern PHP client for Basecamp 4 (BC3 API) — OAuth 2.0 with refresh-token rotation

0.3.0(4w ago)0139—0%MITPHPPHP ^8.4CI passing

Since Jun 10Pushed 4w agoCompare

[ Source](https://github.com/dmstr/php-bc4-client)[ Packagist](https://packagist.org/packages/dmstr/php-bc4-client)[ RSS](/packages/dmstr-php-bc4-client/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)Dependencies (12)Versions (4)Used By (0)

php-bc4-client
==============

[](#php-bc4-client)

Modern PHP 8.4 client for the Basecamp 4 API (which is hosted at `https://3.basecampapi.com/{account_id}/...` and follows the BC3 API specification).

Built on **Symfony HttpClient**, with a small surface area focused on what real applications need: Projects, Todolists, Todos, People, plus a complete OAuth 2.0 flow including transparent refresh-token rotation.

Features
--------

[](#features)

- **OAuth 2.0** web-server flow with Launchpad (`launchpad.37signals.com`)
- **Refresh-token rotation**: tokens are rotated on every refresh and persisted via a pluggable `TokenStorageInterface` — your application picks the storage backend (Doctrine, Redis, file, in-memory)
- **Transparent token lifecycle**: proactive refresh when `expires_at` is near, reactive refresh on `401`, automatic single retry of the original request
- **Rate-limit aware**: exponential backoff on `429`, configurable retry count
- **`invalid_grant` detection**: throws `InvalidGrantException` when the refresh token is rejected, signalling that a fresh user-authorization is required
- **Pagination** via `Link: ; rel="next"` headers, transparent for callers
- **Resource-oriented API**: `$client->projects()->all()`, `$client->todos()->getInProject($id, $todolistId)` etc.

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

[](#installation)

```
composer require dmstr/php-bc4-client
```

Minimum Usage
-------------

[](#minimum-usage)

```
use Dmstr\Bc4Client\Authentication\OAuth2Authentication;
use Dmstr\Bc4Client\Client\Bc4Client;

$auth = new OAuth2Authentication(
    clientId: 'YOUR_CLIENT_ID',
    clientSecret: 'YOUR_CLIENT_SECRET',
    appName: 'My App',
    appContact: 'ops@example.com',
    storage: $myTokenStorage,    // implements TokenStorageInterface
);

$client = new Bc4Client(accountId: '6164391', authentication: $auth);

foreach ($client->projects()->all() as $project) {
    echo $project['name'], "\n";
}
```

Architecture
------------

[](#architecture)

```
Authentication/
  AuthenticationInterface         — minimal request-decoration contract
  OAuth2Authentication            — Bearer token, refresh lifecycle
  TokenStorageInterface           — your app implements this
  AuthorizationFlow               — initial code → tokens, account discovery
Client/
  Bc4Client                       — entrypoint, hands out resources
Exception/
  Bc4ApiException                 — base exception
  InvalidGrantException           — refresh token rejected
  RequestException                — wrapped HTTP error
Resource/
  AbstractResource                — pagination + request helper
  ProjectsResource
  TodoSetsResource
  TodolistsResource
  TodosResource
  PeopleResource

```

Inspired by
-----------

[](#inspired-by)

- [`schmunk42/php-bcx-client`](https://github.com/schmunk42/php-bcx-client) — the BC2 (BCX-API) sibling

License
-------

[](#license)

MIT

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance94

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

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

Total

3

Last Release

29d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3b4ab2b6685ec71887908ec8cff261a16cd5bb24c69bb8ab52840e220f175f9d?d=identicon)[schmunk](/maintainers/schmunk)

---

Top Contributors

[![schmunk42](https://avatars.githubusercontent.com/u/649031?v=4)](https://github.com/schmunk42 "schmunk42 (8 commits)")

---

Tags

apiclientoauthbasecampbasecamp4bc3-api

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dmstr-php-bc4-client/health.svg)

```
[![Health](https://phpackages.com/badges/dmstr-php-bc4-client/health.svg)](https://phpackages.com/packages/dmstr-php-bc4-client)
```

###  Alternatives

[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k13.0M221](/packages/simplesamlphp-simplesamlphp)[sylius/sylius

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

8.5k5.9M754](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[bitrix24/b24phpsdk

An official PHP library for the Bitrix24 REST API

10244.2k5](/packages/bitrix24-b24phpsdk)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k16](/packages/tempest-framework)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M602](/packages/shopware-core)

PHPackages © 2026

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