Download the PHP package slashid/php without Composer

On this page you can find all versions of the php package slashid/php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php

SlashID SDK

Installation

Install this library with composer:

Usage

Instantiating the SDK

First, create a SDK instance, informing the following:

Making requests

You can do direct web service requests with the methods ->get, ->post, ->patch, ->put, ->delete.

GET request

The get method can be used for both index-style endpoints and get-one endpoints.

You can use the second argument to specify a query to the endpoint:

POST, PATCH, PUT requests

For POST, PATCH, PUT requests, you need to pass a body as a second parameter:

DELETE requests

DELETE requests don't return anything:

Some endpoints require a query as well:

getClient()

The methods $sdk->get(), $sdk->post(), $sdk->patch(), $sdk->put() and $sdk->delete() expect sending and receiving JSON, but some endpoints have special requirements, e.g. GET /persons/bulk-import (Fetch the import CSV template) will return a CSV and requires a Accept: text/csv header.

For those cases, you can use $sdk->getClient() to retrieve the underlying GuzzlePHP client with the proper credentials preset, for instance:

Exceptions

The following exceptions may be thrown in case of errors during the connection:

All of \SlashId\Php\Exception exceptions are descendants of \GuzzleHttp\Exception\BadResponseException, which means that you can use the following methods to learn about the causes of the error:

\SlashId\Php\PersonInterface / \SlashId\Php\Person

The Person class is very useful for representing Person information coming from the /persons/{id} endpoint.

You can instantiate a class with Person::fromValues, using the response from the endpoint.

With that, you have several functions to read the person's data:

We also have the respective setters:

:warning: Note that the methods in this class will NOT update the data in SlashID servers. To do that, you must make a request PATCH /persons/:person_id or a request PUT /persons.

Attributes

The person attributes in SlashID are stored in buckets. They are represented in this SDK by the following constants.

Constant Bucket name Scope End-user access
PersonInterface::BUCKET_ORGANIZATION_END_USER_NO_ACCESS 'end_user_no_access' Organization No access
PersonInterface::BUCKET_ORGANIZATION_END_USER_READ_ONLY 'end_user_read_only' Organization Read-only
PersonInterface::BUCKET_ORGANIZATION_END_USER_READ_WRITE 'end_user_read_write' Organization Read-write
PersonInterface::BUCKET_PERSON_POOL_END_USER_NO_ACCESS 'person_pool-end_user_no_access' Person-pool No access
PersonInterface::BUCKET_PERSON_POOL_END_USER_READ_ONLY 'person_pool-end_user_read_only' Person-pool Read-only
PersonInterface::BUCKET_PERSON_POOL_END_USER_READ_WRITE 'person_pool-end_user_read_write' Person-pool Read-write

:warning: Be careful not to expose "NO_ACCESS" attributes to the end-user.

In the Person, the attributes are accessible with the following methods:

The attributes can also be set:

:warning: Note that the methods in this class will NOT update the data in SlashID servers. To do that, you must do a request PUT /persons/:person_id/attributes or /persons/:person_id/attributes/:bucket_name.

Groups

The Person class also has three useful methods to test the person's groups:

Migration Abstraction

The migration abstraction is a class to bulk importing users.

To import users, you must first create an array of \SlashId\Php\PersonInterface and then call $sdk->migration()->migratePersons($persons);, for instance:

The $response will have the response of the endpoint POST /persons/bulk-import, i.e., an array with three keys:

Token Abstraction

The token abstraction is a class to help validating and manipulating the token used for authentication.

Validating token

To validate an authentication token, use the method validateToken:

Getting the person ID from the token

To get the Person ID (the "sub" in the token), use the method getSubFromToken:

Webhook Abstraction

The webhook abstraction is a class to help work with webhooks, for creating, listing, and deleting them, and also adding and removing triggers.

You can access it with:

Listing webhooks

The method findAll() lists all existing webhook listeners in the organization, including listeners in other applications and environments:

The method findById($id) fetches one single webhook when you have its ID.

The method findByUrl($url) fetches one single webhook when you have its URL.

Creating webhooks and setting triggers

The register($url, $name, $triggers, $options) method is idempotent, i.e., it will either create a webhook if it doesn't exist yet or update it if there is already a webhook with that URL. After creating or updating the webhook, it will also register triggers for it. Thus, this method combines calls to /organizations/webhooks and /organizations/webhooks/:webhook_id/triggers endpoints.

A few notes:

  1. The $triggers argument is a list of triggers the webhook will have. For the full list see: https://developer.slashid.dev/docs/access/guides/webhooks/introduction
  2. If the webhook is being updated, the $triggers will override existing triggers.
  3. The $options argument is a list of additional fields the /organizations/webhooks endpoint receives (see https://developer.slashid.dev/docs/api/post-organizations-webhooks), e.g.:

  4. If the webhook is being updated, the $options will NOT override existing values, unlike $triggers.

A few examples:

Setting triggers

You can also handle triggers directly.

The method setTriggers($id, $triggers) will override existing triggers, deleting triggers that are not in the $triggers list and adding new ones that are not.

The method addWebhookTrigger($id, $trigger) adds one single trigger from a webhook.

The method deleteWebhookTrigger($id, $trigger) removes one single trigger from a webhook.

Deleting webhooks

You can delete a webhook with either the deleteById($id) or deleteByUrl($url) methods.

Webhook callback

After you register a webhook and add triggers, SlashID servers will start sending requests to your endpoint. The request will be a JWT that you will have to decode and validate, using keys provided by an API endpoint using the JSON Web Signature standard.

Since the JWT Key Set (JWKS) must be downloaded remotely, it's important to cache the keys in order not to keep making remote requests all the time. So, when calling decodeWebhookCall, you have to a PSR-6-compatible \Psr\Cache\CacheItemPoolInterface object.

Some frameworks provide PSR-6 implementations by default:

For other frameworks, check this list: https://packagist.org/providers/psr/cache-implementation

To implement a webhook listener, fetch the encoded JWT from the body of the remote request, then call decodeWebhookCall to have it validated and decoded. Here's an example of a Laravel implementation that dispatches an Event after receiving the webhook.


All versions of php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
firebase/php-jwt Version ^6.10
guzzlehttp/guzzle Version ^7.2
psr/cache Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package slashid/php contains the following files

Loading the files please wait ....