deschutesdesigngroupllc / perscom-php-sdk
The PERSCOM PHP SDK is a powerful tool that enables seamless integration with the PERSCOM platform, allowing you to interact with PERSCOM's personnel data programmatically.
Fund package maintenance!
Buy Me A Coffee
Installs: 629
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Type:project
pkg:composer/deschutesdesigngroupllc/perscom-php-sdk
Requires
- php: ^8.2
- illuminate/support: ^10 | ^11 | ^12
- saloonphp/rate-limit-plugin: ^2.0
- saloonphp/saloon: ^3.13.0
Requires (Dev)
- laravel/pint: ^1.22.1
- mockery/mockery: ^1.6.7
- pestphp/pest: ^3.8.2
- pestphp/pest-plugin-arch: ^3.1.1
- pestphp/pest-plugin-type-coverage: ^3.0
- phpstan/phpstan: 1.12.4
- dev-master
- v3.0.1
- v3.0.0
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.1
- v2.1.0
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- 1.0.3
- 1.0.0
- dev-develop
- dev-dependabot/composer/develop/illuminate/support-12.41.1
- dev-dependabot/composer/develop/laravel/pint-1.26.0
- dev-feature/claude
This package is auto-updated.
Last update: 2025-12-11 22:44:16 UTC
README
The Official PERSCOM PHP SDK
A PHP package that helps kickstart your next PERSCOM integration.
Introduction
The PERSCOM PHP SDK is a powerful tool that enables seamless integration with the PERSCOM platform, allowing you to interact with PERSCOM's personnel data programmatically.
Getting Started
You can install the package using Composer:
composer require deschutesdesigngroupllc/perscom-php-sdk
Documentation
Visit our documentation here to get started.
Usage
Below is an overview of common usages for the SDK.
<?php use Perscom\PerscomConnection; use Perscom\Data\ResourceObject; use Perscom\Data\SortObject; use Perscom\Data\FilterObject; // The following are examples on the user resource, but the same principles // can be applied to any PERSCOM resource. $perscom = new PerscomConnection('YOUR_API_KEY'); // Optionally include your PERSCOM ID for better request identification // $perscom = new PerscomConnection('YOUR_API_KEY', 'YOUR_PERSCOM_ID'); // For custom base URLs (advanced usage) // $perscom = new PerscomConnection('YOUR_API_KEY', 'YOUR_PERSCOM_ID', 'https://staging.perscom.io'); // Get a list of a specific resource $response = $perscom->users()->all(); // Get a specific resource $response = $perscom->users()->get(id: 1); // Create a resource $response = $perscom->users()->create(data: [ 'name' => 'User 1', 'email' => 'user1@email.com' ]); // Update a resource $response = $perscom->users()->update(id: 1, data: [ 'name' => 'User 1 New Name' ]); // Delete a resource $response = $perscom->users()->delete(id: 1); // Search for a resource $response = $perscom->users()->search( value: 'foobar', sort: new SortObject('first_name', 'asc'), filter: new FilterObject('created_at', '<', '2024-01-01') ); // Batch create a resource $response = $perscom->users()->batchCreate([ new ResourceObject(data: [ 'name' => 'User 1', 'email' => 'user1@email.com' ]), new ResourceObject(data: [ 'name' => 'User 2', 'email' => 'user2@email.com' ]) ]); // Batch update a resource $response = $perscom->users()->batchUpdate([ new ResourceObject(id: 1, data: [ 'name' => 'User 1 New Name' ]), new ResourceObject(id: 2, data: [ 'name' => 'User 2 New Name' ]) ]); // Batch delete a resource $response = $perscom->users()->batchDelete([ new ResourceObject(id: 1), new ResourceObject(id: 2) ]); // Uploading an attachment $response = $perscom->users()->attachments(userId: 1)->create(data: [ 'name' => 'Attachment 1', 'file' => fopen('/../file.pdf', 'r') ]); // Other examples $response = $perscom->users()->profilePhoto(userId: 1)->create(filePath: 'image.jpg'); $response = $perscom->users()->assignmentRecords(userId: 1)->delete(id: 1); // Parse the response into a usable array $data = $response->json();
Error Handling
The PERSCOM SDK throws exceptions when an API error occurs. You can catch these exceptions and handle them accordingly with a standard try/catch block. For a more elegant approach to error handling, consider using the promise-based approach.
use Perscom\PerscomConnection; use Perscom\Exceptions\AuthenticationException; try { $perscom = new PerscomConnection('YOUR_API_KEY'); $response = $perscom->users()->all()->json(); } catch (AuthenticationException $exception) { Log::error('The provided API key is invalid'); }
Promise Support
The PERSCOM SDK can send asynchronous requests using a promise-based approach. This allows you to handle both successful and failed requests in a more fluent way.
use Perscom\PerscomConnection; use Perscom\Http\Requests\Crud\GetAllRequest; use Saloon\Http\Response; use Saloon\Exceptions\Request\RequestException; // Create a PERSCOM instance $perscom = new PerscomConnection('YOUR_API_KEY'); // Create a promise $promise = $perscom->sendAsync(new GetAllRequest('users')); // Send the request $promise ->then(function (Response $response) { // Handle successful response }) ->otherwise(function (RequestException $exception) { // Handle failed request }); // Resolve the promise $promise->wait();
Contributing
Please see here for more details about contributing.
