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

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

snapauth/sdk
============

SnapAuth SDK

0.3.0(8mo ago)1625[4 issues](https://github.com/snapauthapp/sdk-php/issues)[2 PRs](https://github.com/snapauthapp/sdk-php/pulls)BSD-3-ClausePHPPHP ^8.1CI passing

Since Apr 1Pushed 7mo agoCompare

[ Source](https://github.com/snapauthapp/sdk-php)[ Packagist](https://packagist.org/packages/snapauth/sdk)[ RSS](/packages/snapauth-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (7)Versions (13)Used By (0)

SnapAuth PHP SDK
================

[](#snapauth-php-sdk)

This is the official PHP SDK for [SnapAuth](https://www.snapauth.app).

[![Latest Stable Version](https://camo.githubusercontent.com/25ba071b8e5823242ec7da274f96edcc98808a4302cded1564c19ebbdda38fa5/68747470733a2f2f706f7365722e707567782e6f72672f736e6170617574682f73646b2f76)](https://packagist.org/packages/snapauth/sdk)[![PHP Version Require](https://camo.githubusercontent.com/a65e78090e18ac3d400f8f567aec451b066a1bc74f4ad73eae7a6d3b97796107/68747470733a2f2f706f7365722e707567782e6f72672f736e6170617574682f73646b2f726571756972652f706870)](https://packagist.org/packages/snapauth/sdk)[![License](https://camo.githubusercontent.com/a82b44ddb820ed6186605d1c208d748e5cd328d188614c0b5689f69965129092/68747470733a2f2f706f7365722e707567782e6f72672f736e6170617574682f73646b2f6c6963656e7365)](https://packagist.org/packages/snapauth/sdk)

[![Test](https://github.com/snapauthapp/sdk-php/actions/workflows/test.yml/badge.svg)](https://github.com/snapauthapp/sdk-php/actions/workflows/test.yml)[![Lint](https://github.com/snapauthapp/sdk-php/actions/workflows/lint.yml/badge.svg)](https://github.com/snapauthapp/sdk-php/actions/workflows/lint.yml)[![Static analysis](https://github.com/snapauthapp/sdk-php/actions/workflows/static-analysis.yml/badge.svg)](https://github.com/snapauthapp/sdk-php/actions/workflows/static-analysis.yml)

Documentation
-------------

[](#documentation)

Full API and usage docs are available [at the official site](https://docs.snapauth.app/server.html#introduction).

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

[](#installation)

```
composer require snapauth/sdk
```

Setup
-----

[](#setup)

Get your *secret* key from the [dashboard](https://dashboard.snapauth.app). Provide it to the `SnapAuth\Client` class:

```
use SnapAuth\Client;

$yourSecret = getenv('SNAPAUTH_SECRET_KEY');
$snapAuth = new Client(secretKey: $yourSecret);
```

Tip

Secret keys are specific to an environment and domain. We HIGHLY RECOMMEND using environment variables or another external storage mechanism. Avoid committing them to version control, as this can more easily lead to compromise.

The SDK will auto-detect the `SNAPAUTH_SECRET_KEY` environment variable if you do not provide a value directly.

Usage
-----

[](#usage)

### Registration

[](#registration)

Once you obtain a registration token from your frontend, use the `Client` to complete the process and attach it to the user:

```
$token = 'value_from_frontend'; // $_POST['snapauth_token'] or similar
$userInfo = [
  'id' => 'your_user_id',
  'username' => 'your_username',
];
$snapAuth->attachRegistration($token, $userInfo);
```

This activates the passkey and associates it with the user. `$userInfo` will be provided back to you during authentication, so you know who is signing in.

`id` should be some sort of *stable* identifer, like a database primary key.

`username` can be anything you want, or omitted entirely. It's a convenience during *client* authentication so you don't need to look up the user id again. This would commonly be the value a user provides to sign in, such as a username or email. It is *not* a given name.

Both must be strings, and can be up to 255 characters long. Lookups during authentication are **case-insensitive**.

Tip

In order to preseve user privacy, we store only a one-way hash of the `username` values. As a result, we cannot return the original value in other API calls.

### Authentication

[](#authentication)

Like registration, you will need to obtain a token from your frontend provided by the client SDK.

Use the `verifyAuthToken` method to get information about the authentication process, in the form of an `AuthResponse` object. This object contains the previously-registered User `id`.

```
$token = 'value_from_frontend'; // $_POST['snapauth_token'] or similar
$authInfo = $snapAuth->verifyAuthToken($token);

// Specific to your application:
$authenticatedUserId = $authInfo->user->id;

// Laravel:
use Illuminate\Support\Facades\Auth;
Auth::loginUsingId($authenticatedUserId);
```

Error Handling
--------------

[](#error-handling)

The SnapAuth SDK is written in a fail-secure manner, and will throw an exception if you're not on the successful path. This helps ensure that your integration is easy and reliable.

You may choose to locally wrap API calls in a `try/catch` block, or let a general application-wide error handler deal with any exceptions.

All SnapAuth exceptions are an `instanceof \SnapAuth\ApiError`.

Compatibility
-------------

[](#compatibility)

We follow semantic versioning, and limit backwards-incompatible changes to major versions (the X in X.Y.Z) only.

The SnapAuth SDK is maintained for all versions of PHP with [current security support](https://www.php.net/supported-versions.php). Since Composer will platform-detect your currently-installed version of PHP, dropping support for older versions is *not* considered a backwards compatibility break (but you may be unable to install newer versions until updating to a supported version of PHP).

Anything marked as `@internal` or any `protected` or `private` method is not considered in scope for backwards-compatibility guarantees. Similarly, all methods should be treated as ones that may throw an exception, and as such new types of exceptions are not considered a BC break either.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance42

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.9% 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 ~59 days

Recently: every ~129 days

Total

10

Last Release

241d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/354842?v=4)[Eric Stern](/maintainers/Firehed)[@Firehed](https://github.com/Firehed)

---

Top Contributors

[![Firehed](https://avatars.githubusercontent.com/u/354842?v=4)](https://github.com/Firehed "Firehed (20 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

passkeysphpsnapauthweb-authenticationweb-authentication-apiwebauthn

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/snapauth-sdk/health.svg)

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

###  Alternatives

[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k172.9M1.8k](/packages/symfony-security-bundle)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)[beatswitch/lock

A flexible, driver based Acl package for PHP 5.4+

870304.7k2](/packages/beatswitch-lock)[amocrm/amocrm-api-library

amoCRM API Client

182728.5k6](/packages/amocrm-amocrm-api-library)[vonage/jwt

A standalone package for creating JWTs for Vonage APIs

424.1M4](/packages/vonage-jwt)

PHPackages © 2026

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