Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/corbado/corbado-php
Add passkeys to your PHP application with the Corbado PHP SDK.
https://github.com/corbado/corbado-php
biometric corbado corbado-sdk faceid fido fido2 laravel passkey passkeys php php-sdk sdk symfony touchid webauthn
Last synced: about 1 month ago
JSON representation
Add passkeys to your PHP application with the Corbado PHP SDK.
- Host: GitHub
- URL: https://github.com/corbado/corbado-php
- Owner: corbado
- License: mit
- Created: 2022-12-23T09:51:22.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-22T19:13:45.000Z (10 months ago)
- Last Synced: 2024-04-25T13:40:45.373Z (7 months ago)
- Topics: biometric, corbado, corbado-sdk, faceid, fido, fido2, laravel, passkey, passkeys, php, php-sdk, sdk, symfony, touchid, webauthn
- Language: PHP
- Homepage: https://www.corbado.com/passkeys/php
- Size: 894 KB
- Stars: 17
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![corbado-php](https://github.com/corbado/corbado-php/assets/18458907/aa4f9df6-980b-4b24-bb2f-d71c0f480971)
# Corbado PHP SDK
[![License](https://poser.pugx.org/corbado/php-sdk/license.svg)](https://packagist.org/packages/corbado/php-sdk)
[![Latest Stable Version](http://poser.pugx.org/corbado/php-sdk/v)](https://packagist.org/packages/corbado/php-sdk)
[![Test Status](https://github.com/corbado/corbado-php/workflows/tests/badge.svg)](https://github.com/corbado/corbado-php/actions?query=workflow%3Atests)
[![documentation](https://img.shields.io/badge/documentation-Corbado_Backend_API_Reference-blue.svg)](https://apireference.cloud.corbado.io/backendapi/)
[![Slack](https://img.shields.io/badge/slack-join%20chat-brightgreen.svg)](https://join.slack.com/t/corbado/shared_invite/zt-1b7867yz8-V~Xr~ngmSGbt7IA~g16ZsQ)The [Corbado](https://www.corbado.com) PHP SDK provides convenient access to the [Corbado Backend API](https://apireference.cloud.corbado.io/backendapi-v2/) from applications written in the PHP language.
:warning: The Corbado PHP SDK is commonly referred to as a private client, specifically designed for usage within closed backend applications. This particular SDK should exclusively be utilized in such environments, as it is crucial to ensure that the API secret remains strictly confidential and is never shared.
:rocket: [Getting started](#rocket-getting-started) | :hammer_and_wrench: [Services](#hammer_and_wrench-services) | :books: [Advanced](#books-advanced) | :speech_balloon: [Support & Feedback](#speech_balloon-support--feedback)
## :rocket: Getting started
### Requirements
- PHP 8.0 or later
- [Composer](https://getcomposer.org/)### Installation
Use the following command to install the Corbado PHP SDK:
```bash
composer require corbado/php-sdk
```### Usage
To create a Corbado PHP SDK instance you need to provide your `Project ID`, `API secret`, `Frontend API URL` and `Backend API URL` which can be found at the [Developer Panel](https://app.corbado.com).
```PHP
$config = new Corbado\Config('', '', '', '');
$sdk = new Corbado\SDK($config);
```### Examples
A list of examples can be found in the integration tests [here](tests/integration).
## :hammer_and_wrench: Services
The Corbado PHP SDK provides the following services:
- `sessions` for managing sessions
- `users` for managing users ([examples](tests/integration/User))
- `identifiers` for managing identifiers ([examples](tests/integration/Identifier))To use a specific service, such as `sessions`, invoke it as shown below:
```PHP
$user = $sdk->sessions()->getCurrentUser();
```## :books: Advanced
### Error handling
The Corbado PHP SDK throws exceptions for all errors. The following exceptions are thrown:
- `AssertException` for failed assertions (client side)
- `ConfigException` for configuration errors (client side)
- `ValidationException` for validation errors (client side)
- `ServerException` for server errors (server side)
- `StandardException` for everything else (client side)If the Backend API returns an HTTP status code other than 200, the Corbado PHP SDK throws a `ServerException`. The `ServerException`class provides convenient methods to access all important data:
```PHP
try {
// Try to get non-existing user with ID 'usr-123456789'
$user = $sdk->users()->get('usr-123456789');
} catch (ServerException $e) {
// Show HTTP status code (400 in this case)
echo $e->getHttpStatusCode() . PHP_EOL;
// Show request ID (can be used in developer panel to look up the full request
// and response, see https://app.corbado.com/app/logs/requests)
echo $e->getRequestID() . PHP_EOL;
// Show full request data
var_dump($e->getRequestData());
// Show runtime of request in seconds (server side)
echo $e->getRuntime() . PHP_EOL;
// Show validation error messages (server side validation in case of HTTP
// status code 400 (Bad Request))
var_dump($e->getValidationMessages());
// Show full error data
var_dump($e->getError());
}
```## :speech_balloon: Support & Feedback
### Report an issue
If you encounter any bugs or have suggestions, please [open an issue](https://github.com/corbado/corbado-php/issues/new).
### Slack channel
Join our Slack channel to discuss questions or ideas with the Corbado team and other developers.
[![Slack](https://img.shields.io/badge/slack-join%20chat-brightgreen.svg)](https://join.slack.com/t/corbado/shared_invite/zt-1b7867yz8-V~Xr~ngmSGbt7IA~g16ZsQ)
You can also reach out to us via email at [email protected].
### Vulnerability reporting
Please report suspected security vulnerabilities in private to [email protected]. Please do NOT create publicly viewable issues for suspected security vulnerabilities.