oilstone / api-salesforce-integration
A Salesforce integration package for garethhudson07/api
Requires
- garethhudson07/aggregate: ^1.2
- garethhudson07/api: ^9.5
- guzzlehttp/guzzle: ^7.9
- nesbot/carbon: ^3.10
Requires (Dev)
- laravel/framework: ^11.0
- oilstone/api-resource-loader: ^5.3
- psr/http-message: ^1.0
- dev-main
- v0.0.4
- v0.0.3
- v0.0.2
- v0.0.1
- dev-codex/rewrite-readme-with-feature-set-and-installation-instruction
- dev-codex/extend-methods-with-conditions,-selects,-and-crud-functional
- dev-codex/separate-repository-from-api-integration
- dev-codex/add-debug-logging-for-salesforce-api-requests
- dev-codex/expand-resource-class-to-support-constraints
- dev-codex/add-default-constraints-to-repository-object
- dev-codex/update-attributes-to-be-record-metadata
- dev-codex/modify-lookup-logic-to-use-ui-api-object-info
- dev-codex/extend-package-for-picklist-values
- dev-codex/add-laravel-integration-with-service-provider
This package is auto-updated.
Last update: 2025-06-19 10:56:40 UTC
README
A lightweight integration for interacting with Salesforce from PHP. The package supplies a stand‑alone client and query builder while also providing adapters for the garethhudson07/api framework.
Features
- Salesforce HTTP client built on Guzzle with convenience helpers for common endpoints.
- Fluent SOQL query builder supporting nested conditions,
IN
clauses, ordering, limits and relationship includes. - Repository layer exposing
find
,first
,get
,create
,update
anddelete
methods for Salesforce objects. - Integration with garethhudson07/api through repository and query bridge classes and a data transformer so that resources defined in that package can query Salesforce seamlessly.
- Laravel support including a service provider for obtaining and caching OAuth tokens and optional request logging.
- Lookup utilities for retrieving and caching pick list values.
- Adapters for api-resource-loader allowing resources to be loaded from configuration files.
Although the package was designed to act as a bridge for garethhudson07/api
, the client, query builder and repository classes can be used independently in any PHP project.
Installation
composer require oilstone/api-salesforce-integration
Optional Laravel setup
If your project uses Laravel you can register the service provider and publish the configuration file:
// config/app.php 'providers' => [ \Oilstone\ApiSalesforceIntegration\Integrations\Laravel\ServiceProvider::class, ],
php artisan vendor:publish --tag=config --provider="Oilstone\\ApiSalesforceIntegration\\Integrations\\Laravel\\ServiceProvider"
Configure your Salesforce instance in config/salesforce.php
and the provider will handle authentication and caching of access tokens. When the debug
option is enabled each request and response is logged via Laravel's logger.
Basic usage
Stand‑alone
use GuzzleHttp\Client; use Oilstone\ApiSalesforceIntegration\Clients\Salesforce; use Oilstone\ApiSalesforceIntegration\Repository; $http = new Client(); $salesforce = new Salesforce($http, $instanceUrl, $accessToken); $accounts = (new Repository('Account')) ->setDefaultConstraints([['Type', 'Customer']]) ->newQuery() ->where('Name', 'like', 'Acme%') ->get();
With garethhudson07/api
Create a resource repository that extends the provided API adapter and let the framework resolve queries against Salesforce:
use Oilstone\ApiSalesforceIntegration\Integrations\Api\Repository as ApiRepository; class AccountRepository extends ApiRepository { protected string $object = 'Account'; }
The package's query resolver and transformer bridge the API pipeline to Salesforce so existing endpoints defined in garethhudson07/api
continue to work with Salesforce data.
Lookups
Extend Lookup
or CachedLookup
to pull picklist values from Salesforce:
class IndustryLookup extends CachedLookup { public static function object(): string { return 'Account'; } public static function field(): string { return 'Industry'; } public static function recordTypeId(): string { return '0123...'; } } $industries = IndustryLookup::all();
Exceptions
SalesforceException
is thrown for non‑successful responses and provides access to the underlying error details via getErrors()
.
License
This package is released under the MIT license.