Download the PHP package serato/sws-php-sdk without Composer

On this page you can find all versions of the php package serato/sws-php-sdk. 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 sws-php-sdk

Serato SWS PHP SDK

A PHP SDK for interacting with SWS web services.

Note: currently limited to applications that use the Server Side Application Authorisation Workflow

All PHP code within the Serato Checkout library exists within the Serato\SwsSdk namespace.

Style guide

Please ensure code adheres to the PHP-FIG PSR-2 Coding Style Guide

Use PHP_CodeSniffer to validate your code against coding standards:

$ ./vendor/bin/phpcs

PHPStan

Use PHPStan for static code analysis:

Unit tests

Configuration for PHPUnit is defined within phpunit.xml.

To run tests:

$ php vendor/bin/phpunit

Usage

Key Concepts

Configuring the SDK

Using the Serato\SwsSdk\Sdk::create static method

The Serato\SwsSdk\Sdk::create static method is the preferred way to create an SDK instance. The method requires a Serato\ServiceDiscovery\HostName instance and derives endpoint URIs for the SWS web services from this instance.

It also requires a client application ID amd client application password.

It can optionally be provided with an HTTP request timeout (a float representing a number of seconds), and a callable that transfers HTTP requests over the wire within the underlying Guzzle HTTP library (typically this is used to provide a mock request handler for testing purposes).

Using the Serato\SwsSdk\Sdk constructor

In almost all cases the Serato\SwsSdk\Sdk::create method is the preferred way of configuring the SDK. But if you need to provide a non-standard configuration to the SDK (eg. using service endpoints from differing environments) you can call the SDK constructor directly.

The Serato\SwsSdk\Sdk constructor takes an $args array, a client application ID amd client application password.

$args is used to specify the endpoints of the various SWS web services, as well as providing additional configuration to the underlying GuzzleHttp\Client.

Custom endpoints can be specified by setting the $args Sdk::BASE_URI key with an array with the following keys:

The value of each key is the full base URI (including protocol) of the respective SWS web services.

$args can take a 'timeout' key which sets the request timeout for all requests. Timeout values are floats representing the number of seconds before the request times out.

$args can also take a 'handler' key that defines a custom HTTP handler for use by the underlying GuzzleHttp library. The primary use for this is for mocking various HTTP responses (see Testing clients below for more).

Creating clients

An instance of Serato\SwsSdk\Sdk can be used to create service clients.

A clients interacts with a specific SWS service using the configuration parameters passed to a Serato\SwsSdk\Sdk instance.

There are currently six clients available:

Executing commands

Commands correspond to a specific endpoint on an SWS service. Commands require arguments that map directly to the request parameters allowed by the corresponding endpoint.

The PHP API documention lists the allowed arguments for each command class.

Commands can be explictly created then passed to the Serato\SwsSdk\Client::executeCommand method. But it is simpler to use the magic methods of a client that map a command to a client method name.

The PHP API documention provides the magic method name for each command class.

Working with Results

A successfully executed command returns a Serato\SwsSdk\Result instance.

A Result object takes a response from a SWS web service and parses the message body so that the contents of the response body can be accessed using native PHP array accessor syntax.

The Result object also has a Result::getResponse method that returns the underlying Psr\Http\Message\ResponseInterface response object.

Exceptions

When a command execution results in a non-200 HTTP response from a SWS web service an exeception is thrown.

All exception classes in the SDK extend Serato\SwsSdk\Exception\ResponseException. ResponseException extends the base PHP RuntimeException class.

ResponseException classes have a ResponseException::getResult method which returns a Result object, providing access the underlying response from the web service.

Specific exception classes handle each type of expected non-200 HTTP response. The code property of the exception class is used in one of two different ways in each child exception class

Requests resulting in connection errors (timeouts, failed DNS lookups etc) do not throw SDK-specific exceptions and instead throw a GuzzleHttp\Exception\ConnectException provided by Guzzle.

Testing clients

Because clients in the SDK extend GuzzleHttp\Client requests to SWS services can be mocked using Guzzle's GuzzleHttp\Handler\MockHandler.

The Guzzle documentation provides a good overview of how to create mock responses and provide them to a GuzzleHttp\Handler\MockHandler instance.

The mock handler can then be provided to SwsSdk clients via the Serato\SwsSdk\Sdk class.

The mock handler stack can also include exceptions:


All versions of sws-php-sdk with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1
guzzlehttp/guzzle Version ^6.0.0
serato/sws-discovery Version ^2.0.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 serato/sws-php-sdk contains the following files

Loading the files please wait ....