承接 pawanmore/stytch-php-sdk 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pawanmore/stytch-php-sdk

Composer 安装命令:

composer require pawanmore/stytch-php-sdk

包简介

UnOfficial PHP SDK for Stytch Authentication APIs

README 文档

README

Latest Stable Version

Stytch PHP SDK

PHP SDK for Stytch Authentication APIs. This SDK provides easy-to-use methods for integrating Stytch's authentication services into your PHP applications.

Features

  • B2B API Support: Complete coverage of Stytch's B2B authentication APIs
  • Consumer API Support: Full support for consumer authentication endpoints
  • Modern PHP: Built for PHP 7.4+ with modern features
  • Type Safety: Full type hints and documentation
  • Error Handling: Comprehensive error handling and exceptions
  • PSR Standards: Follows PSR-4 autoloading and PSR-7 HTTP standards

Installation

Via Composer

composer require pawanmore/stytch-php-sdk

Manual Installation

  1. Clone this repository
  2. Run composer install
  3. Include the autoloader in your project

Quick Start

Initialize the SDK

<?php

use Stytch\StytchClient;

// Initialize with your project credentials
$stytch = new StytchClient([
    'project_id' => 'your-project-id',
    'secret' => 'your-secret-key',
    'env' => 'test' // or 'live'
]);

B2B API Examples

// Create an organization
$response = $stytch->b2b->organizations->create([
    'organization_name' => 'My Company',
    'organization_slug' => 'my-company'
]);

// Create a member
$response = $stytch->b2b->members->create([
    'organization_id' => 'org_123',
    'email_address' => 'user@company.com'
]);

// Send magic link
$response = $stytch->b2b->magicLinks->send([
    'organization_id' => 'org_123',
    'email_address' => 'user@company.com'
]);

Consumer API Examples

// Create a user
$response = $stytch->consumer->users->create([
    'email' => 'user@example.com'
]);

// Send magic link
$response = $stytch->consumer->magicLinks->send([
    'email' => 'user@example.com'
]);

// Authenticate magic link
$response = $stytch->consumer->magicLinks->authenticate([
    'token' => 'magic_link_token'
]);

API Coverage

B2B API

  • Organizations: Create, get, update, search, delete
  • Members: Create, get, update, search, delete, reactivate
  • RBAC: Get RBAC policies
  • Magic Links: Send, authenticate, discovery
  • OAuth: Google, Microsoft authentication
  • Session Management: Get, authenticate, exchange, revoke
  • SSO: SAML, OIDC connections
  • Discovery: List organizations, create via discovery
  • Passwords: Authenticate, reset, strength check, migrate
  • MFA: TOTP, OTP, recovery codes
  • M2M: Client management, access tokens
  • Email OTP: Send, authenticate
  • Impersonation: Authenticate tokens

Consumer API

  • Users: Create, get, update, search, delete
  • Magic Links: Send, authenticate, embeddable
  • OTP: SMS, WhatsApp, email
  • OAuth: Multiple providers (Google, Apple, GitHub, etc.)
  • Session Management: Get, authenticate, revoke
  • TOTP: Create, authenticate, recovery codes
  • Crypto Wallets: Authenticate
  • Passkeys & WebAuthn: Register, authenticate
  • Passwords: Authenticate, reset, strength check

Error Handling

The SDK throws specific exceptions for different error types:

try {
    $response = $stytch->consumer->users->create(['email' => 'invalid-email']);
} catch (Stytch\Exceptions\StytchException $e) {
    echo "Stytch Error: " . $e->getMessage();
} catch (Stytch\Exceptions\StytchError $e) {
    echo "API Error: " . $e->getMessage();
    echo "Error Code: " . $e->getErrorCode();
}

Configuration

Environment Variables

You can also configure the SDK using environment variables:

STYTCH_PROJECT_ID=your-project-id
STYTCH_SECRET=your-secret-key
STYTCH_ENV=test

Advanced Configuration

$stytch = new StytchClient([
    'project_id' => 'your-project-id',
    'secret' => 'your-secret-key',
    'env' => 'test',
    'timeout' => 30,
    'user_agent' => 'MyApp/1.0',
    'http_client' => new CustomHttpClient()
]);

Testing

Run the test suite:

composer test

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Support

pawanmore/stytch-php-sdk 适用场景与选型建议

pawanmore/stytch-php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「api」 「Authentication」 「oauth」 「SSO」 「unofficial」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 pawanmore/stytch-php-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 pawanmore/stytch-php-sdk 我们能提供哪些服务?
定制开发 / 二次开发

基于 pawanmore/stytch-php-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 27
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-08