intercom/intercom-php
Intercom PHP SDK for PHP 8.1+ that makes it easy to call Intercom APIs. Instantiate IntercomClient with your token, use typed request objects, handle IntercomApiException for 4xx/5xx errors, and iterate list endpoints with automatic pagination via Pager.
Pros:
Pager<T>) and exponential backoff retries reduce boilerplate for common API workflows.Cons:
IntercomClient instance manages all resources, which may not align with microservice architectures or granular dependency injection (DI) needs.bind() or make()) due to PSR-11 compliance.Http\Adapter\Guzzle6) is pre-configured for compatibility.IntercomApiException caught in middleware).setClient() → setHttpClient()).array_unpack for older PHP).guzzlehttp/guzzle or php-http packages if not managed via Composer’s conflict or replace directives.maxRetries tuning.IntercomApiException be logged/retried? Should Laravel’s App\Exceptions\Handler normalize these errors?MockHandler.Http::fake() (if using Laravel HTTP client).env() or Vault)? Should it be scoped per environment?Intercom\Legacy\...), what’s the timeline to migrate to the new SDK?$this->app->singleton(IntercomClient::class, function ($app) {
return new IntercomClient(
token: config('services.intercom.token'),
options: [
'client' => $app->make(\Http\Client\Common\HttpClient::class),
]
);
});
Http facade or HttpClient (v10+) for consistency:
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;
$client = new IntercomClient(
token: config('intercom.token'),
options: ['client' => new GuzzleAdapter(new \GuzzleHttp\Client())]
);
app()->make():
$handlerStack = HandlerStack::create();
$handlerStack->push(new RetryMiddleware());
$client = new IntercomClient([
'client' => new \GuzzleHttp\Client(['handler' => $handlerStack]),
]);
class UpdateIntercomContact implements ShouldQueue
{
public function handle() {
$client->contacts->update($contactId, $data);
}
}
Intercom\Legacy\... calls).$newClient = new IntercomClient(config('intercom.token'));
$legacyClient = new \Intercom\Legacy\IntercomClient(config('intercom.token'));
contacts->update()).config('intercom.use_new_sdk')).composer require intercom/intercom-php:^5.1.0).composer require php:^8.1 and polyfills for older versions.composer.json:
"conflict": {
"guzzlehttp/guzzle": ">=7.0,<8.0"
},
"replace": {
"php-http/httplug": "self.version"
}
contacts->create(), companies->list()).Http::fake()).foreach ($contacts as $contact)).AppServiceProvider).intercom.api.latency).env() or Hashicorp Vault).dd() or Log::debug() to inspect IntercomApiException payloads:
catch (Inter
How can I help you explore Laravel packages today?