Download the PHP package stytch/stytch-php without Composer
On this page you can find all versions of the php package stytch/stytch-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download stytch/stytch-php
More information about stytch/stytch-php
Files in stytch/stytch-php
Package stytch-php
Short Description Stytch PHP SDK
License MIT
Homepage https://stytch.com
Informations about the package stytch-php
Stytch PHP SDK
The Stytch PHP SDK makes it simple to integrate Stytch into your PHP application.
Installation
Install the SDK using Composer:
Usage
Consumer (B2C) Client
B2B Client
Environment
The SDK supports both test and live environments:
test: Useshttps://test.stytch.comlive: Useshttps://api.stytch.com
If no environment is specified, the SDK will auto-detect based on your project ID.
Async API Support
All SDK methods have async counterparts that return Guzzle Promises, allowing for non-blocking operations and concurrent requests.
Basic Async Usage
Concurrent Requests
Advanced Promise Usage
Error Handling
The SDK throws StytchException for API errors:
Async Error Handling
Async methods handle errors through promise rejection:
Requirements
- PHP 8.1 or higher
- Guzzle HTTP client
Upgrading to 2.0
PHP 8.4 Compatibility
Version 2.0 adds full support for PHP 8.4 by using explicit nullable type declarations. If you're using PHP 8.4 with strict deprecation handling (common in PHPUnit/Laravel test environments), you must upgrade to v2.0+ to avoid deprecation errors.
Fixed in v2.0:
Breaking Changes
WhatsApp OTP Namespace Change
The WhatsApp OTP class has been renamed to fix capitalization:
Impact: Only affects code that directly imports or type-hints the OTPsWhatsapp class. The property access $client->otps->whatsapp remains unchanged.
New Features in 2.0
- Local JWT Authentication: Authenticate JWTs locally without making an API call
- RBAC Organization Policies: Set and retrieve organization-specific RBAC policies
- External ID Management: Delete external IDs for users and organization members
- DFP Email Risk API: New device fingerprinting email risk endpoint
Testing
The SDK includes a comprehensive test suite covering both Consumer and B2B functionality.
Setup Tests
-
Set up environment variables:
- Install test dependencies:
Running Tests
Test Coverage
The test suite covers:
Consumer API:
- Users: create, get, update, delete, search (sync & async)
- Passwords: create, authenticate, strength check, reset operations (sync & async)
- Sessions: authenticate, get, revoke, exchange (sync & async)
- Magic Links: send, authenticate, invite operations (sync & async)
B2B API:
- Organizations: create, get, update, delete, search (sync & async)
- Organization Members: create, get, update, delete, search, reactivate (sync & async)
- Passwords: create, authenticate, strength check, reset operations, discovery (sync & async)
Async Functionality:
- Core HTTP client async methods (GET, POST, PUT, DELETE)
- Promise chaining and error handling
- Concurrent request processing
- Integration with all API classes
See tests/README.md for detailed testing documentation.
Development
Project Structure
Code Quality
This project uses:
- PHPStan for static analysis
- PHPUnit for testing
- PSR-4 autoloading
- PSR-12 coding standards
Run code quality checks:
Contributing
Please see our contribution guidelines for details on how to contribute to this project.
License
This project is licensed under the MIT License - see the LICENSE file for details.