Download the PHP package stitch-digital/simpro-php-sdk without Composer

On this page you can find all versions of the php package stitch-digital/simpro-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 simpro-php-sdk

Simpro PHP SDK

Latest Version on Packagist Total Downloads

This package is an unofficial PHP SDK for the Simpro API, built with Saloon.

✅ Stable Release

This package is stable and ready for production use. It follows semantic versioning, so breaking changes will only ever land in a new major version.

New API resources and endpoints are still being added, but existing ones will not change in a backwards-incompatible way within the 1.x line.

About Simpro

Simpro is a cloud-based field service management platform designed for trade and service contractors, supporting industries such as fire protection, electrical, plumbing, HVAC, and security. It helps businesses manage jobs, quoting, scheduling, asset registers, compliance, and invoicing in one central system, replacing spreadsheets and disconnected tools with a mobile-friendly platform where technicians can capture job data, photos, and service results on site while office teams manage workflows, customer communication, and reporting, with integrations into accounting and other business software.

Table of Contents

Installation

Quick Start

Choose the authentication method that fits your use case. See the Authentication Methods section below for details.

Behind the scenes, the SDK uses Saloon v3 to make HTTP requests.

Authentication Methods

This SDL supports two authentication methods. Choose the one that best fits your use case:

OAuth (Authorization Code Grant)

Best for: Web applications where users can be redirected to Simpro's authorization page.

This flow requires users to approve access to your application. After approval, they're redirected back with a code you exchange for an access token.

Token Management:

The AccessTokenAuthenticator returned by getAccessToken() contains:

You should securely store this (encrypted) in your database and check for expiration before each request.

API Key

Best for: Server-to-server integrations, background jobs, and command-line tools.

This is the simplest authentication method - just provide your API key and start making requests.

That's it! No token management, no refresh logic - just simple, straightforward authentication.

Usage

Authentication

The SDK supports two authentication methods. See the Authentication Methods section above for detailed information:

Setting a timeout

By default, the SDK waits 10 seconds for a response. Override via the constructor:

Rate Limiting

The SDK automatically handles Simpro's API rate limit of 10 requests per second per base URL. By default, when the limit is reached, the SDK waits and retries automatically.

See Simpro's API documentation for more details on rate limits.

Default Behavior

Rate limiting is enabled by default with sensible settings:

With default settings:

Custom Store

For applications running multiple processes or workers, use a persistent store to share rate limit state:

For Laravel applications, you can use a cache-based store:

See Saloon's Rate Limit Plugin documentation for all available stores.

Throwing Exceptions

For queue jobs or situations where you want to handle rate limits yourself, configure the SDK to throw exceptions instead of sleeping:

Disabling Rate Limiting

If you need to disable rate limiting entirely:

Caching

The SDK supports response caching using Saloon's cache plugin. Caching is opt-in and disabled by default - you must provide a CacheConfig to enable it.

Enabling Caching

You can enable caching using any PSR-16 compatible cache, Laravel's cache system, or Flysystem:

Cache Options

Configure cache expiry and key prefix:

Cache Behavior

Aspect Behavior
Default state Disabled (opt-in)
Cached methods GET and OPTIONS only
Cached responses Successful responses only
Cache key prefix simpro:{hostname}[:userPrefix]:{hash}
Default expiry 300 seconds (5 minutes)

Cache keys are automatically prefixed with the Simpro instance hostname to ensure multi-tenant isolation.

Enabling Caching After Construction

You can also enable or disable caching after creating the connector:

Checking Cache Status

After sending a request, you can check if the response came from cache:

Disabling Cache for Specific Requests

You can disable caching for individual requests:

Invalidating Cache

To invalidate the cache for a specific request:

See Saloon's Cache Plugin documentation for more details.

Laravel Integration

This section provides guidance for integrating the SDK into Laravel applications. The approach differs depending on whether you're building a single-tenant application (API Key) or a multi-tenant application (OAuth).

API Key Connector (Single-Tenant Applications)

For applications that connect to a single Simpro instance using an API key.

Configuration (config/services.php):

Service Provider Binding (app/Providers/AppServiceProvider.php):

Usage via Dependency Injection:

Optional Facade:

Create a facade for convenient static access:

Usage:

OAuth Connector (Multi-Tenant Applications)

For applications where multiple users connect their own Simpro accounts. This approach requires the Saloon Laravel plugin for the Eloquent cast:

Configuration (config/services.php):

Model (app/Models/SimproConnection.php):

Store the OAuth authenticator and tenant-specific Simpro URL:

Migration:

Factory (app/Services/SimproConnectorFactory.php):

Controller (app/Http/Controllers/SimproOAuthController.php):

Usage Example:

Further Reading

Handling Errors

The SDK uses Saloon's AlwaysThrowOnErrors trait on the connector, which means exceptions will automatically be thrown whenever a request fails (4xx or 5xx response status codes). You don't need to manually check if a request failed or call throw() on responses - exceptions are thrown automatically.

Saloon's built-in exceptions are used for most errors, with a custom exception for validation errors (422 status codes).

Exception Hierarchy

The SDK uses Saloon's exception hierarchy:

Validation Errors

For validation errors (422 status code), the SDK throws a custom ValidationException which extends Saloon's UnprocessableEntityException. This exception provides additional methods to access validation error details:

Connection Errors

If Saloon cannot connect to the API, it will throw a FatalRequestException:

Resources

The SDK provides resource-based APIs for working with different Simpro entities. Each resource has its own documentation page with detailed examples and usage instructions.

Available Resources

Additional resources are added in minor releases as coverage of the Simpro API expands.

Pagination and Querying

Resource methods that return lists use a QueryBuilder instance that provides fluent search, filtering, and ordering capabilities. The query builder wraps Saloon's pagination plugin and handles pagination automatically.

Basic Usage

Fluent Search API

The SDK provides a fluent search API for building complex queries:

Search Methods

The Search class provides these methods:

Method Description Example Value
equals($value) Exact match Test
find($value) Wildcard search %25Test%25
startsWith($value) Starts with Test%25
endsWith($value) Ends with %25Test
lessThan($value) Less than lt(10)
lessThanOrEqual($value) Less than or equal le(10)
greaterThan($value) Greater than gt(10)
greaterThanOrEqual($value) Greater than or equal ge(10)
notEqual($value) Not equal ne(Cancelled)
between($min, $max) Range between(1,100)
in($array) In list in(Active,Pending)
notIn($array) Not in list !in(Cancelled,Deleted)

Using Laravel Collections

The collect() method returns a LazyCollection for powerful data transformations:

Array Filters (Backward Compatible)

You can also pass filters as an array to list methods:

Controlling Page Size

By default, 30 items are fetched per page:

Pagination Metadata

The Simpro API returns pagination information in response headers:

The paginator automatically reads these headers and handles pagination for you.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of simpro-php-sdk with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/collections Version ^11.0 || ^12.0 || ^13.0
saloonphp/cache-plugin Version ^3.0
saloonphp/pagination-plugin Version ^2.2
saloonphp/rate-limit-plugin Version ^2.0
saloonphp/saloon Version ^4.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 stitch-digital/simpro-php-sdk contains the following files

Loading the files please wait ...