Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Intercom Php Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Pros:

    • PSR Standards Compliance: Aligns with PSR-17/PSR-18 (HTTP message factories) and PSR-11 (container interfaces), ensuring compatibility with modern PHP ecosystems (e.g., Laravel, Symfony).
    • HTTPPlug Integration: Abstracts HTTP clients (Guzzle, CURL, etc.), enabling flexibility in infrastructure choices without vendor lock-in.
    • Type Safety: PHP 8.1+ support with strict typing improves maintainability and IDE tooling (e.g., autocompletion, static analysis).
    • Pagination & Retries: Built-in pagination (Pager<T>) and exponential backoff retries reduce boilerplate for common API workflows.
    • Legacy Support: Dual SDK support (new/legacy) eases migration paths for existing codebases.
    • Intercom API Coverage: Supports core resources (Contacts, Companies, Teams, AI Content, Conversations) and API v2.0 features.
  • Cons:

    • Generated SDK: Limited customization (e.g., no manual API endpoint extensions) due to Fern-generated codebase.
    • Monolithic Client: Single IntercomClient instance manages all resources, which may not align with microservice architectures or granular dependency injection (DI) needs.
    • No Async Support: Synchronous-only design may require additional layers (e.g., ReactPHP) for high-throughput use cases.

Integration Feasibility

  • Laravel Compatibility:
    • Native Integration: Works seamlessly with Laravel’s service container (via bind() or make()) due to PSR-11 compliance.
    • HTTP Client: Laravel’s default Guzzle client (Http\Adapter\Guzzle6) is pre-configured for compatibility.
    • Middleware: Supports Laravel’s middleware stack (e.g., logging, rate limiting) via Guzzle middleware injection.
    • Queue Jobs: Can be wrapped in Laravel queues for async Intercom operations (e.g., bulk contact updates).
  • Database Sync: No built-in ORM support (e.g., Eloquent), but can sync Intercom data to Laravel models via events (e.g., IntercomApiException caught in middleware).

Technical Risk

  • Breaking Changes:
    • v4.0.0+: HTTPPlug migration may require refactoring if using deprecated Guzzle-specific methods (e.g., setClient()setHttpClient()).
    • PHP 8.1+: Downgrades to PHP 7.4–8.0 may need polyfills (e.g., array_unpack for older PHP).
  • Dependency Conflicts:
    • Potential version clashes with guzzlehttp/guzzle or php-http packages if not managed via Composer’s conflict or replace directives.
  • Rate Limiting:
    • Default retries (2 attempts) may not suffice for high-volume apps; requires custom maxRetries tuning.
  • Legacy Code:
    • Mixed SDK usage (new/legacy) could lead to inconsistencies if not phased out systematically.

Key Questions

  1. API Versioning:
    • Will the app use Intercom’s API v2.0 (Contacts, Conversations) or legacy endpoints? Does this require feature flags or parallel SDK instances?
  2. Error Handling:
    • How should IntercomApiException be logged/retried? Should Laravel’s App\Exceptions\Handler normalize these errors?
  3. Performance:
    • For bulk operations (e.g., 10K+ contacts), should requests be batched or queued to avoid rate limits?
  4. Testing:
    • How will Intercom API responses be mocked in PHPUnit? Options:
      • Guzzle’s MockHandler.
      • Laravel’s Http::fake() (if using Laravel HTTP client).
  5. Security:
    • Is the Intercom token stored securely (e.g., Laravel’s env() or Vault)? Should it be scoped per environment?
  6. Monitoring:
    • How will API latency/errors be monitored? Options:
      • Laravel Horizon for queue jobs.
      • Custom metrics (e.g., Prometheus) via Guzzle middleware.
  7. Migration Path:
    • If using legacy SDK (Intercom\Legacy\...), what’s the timeline to migrate to the new SDK?

Integration Approach

Stack Fit

  • Laravel Ecosystem:
    • Service Container: Register the client as a singleton or context-bound instance:
      $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 Client: Leverage Laravel’s built-in 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())]
      );
      
    • Middleware: Inject Guzzle middleware (e.g., retry, logging) via Laravel’s app()->make():
      $handlerStack = HandlerStack::create();
      $handlerStack->push(new RetryMiddleware());
      $client = new IntercomClient([
          'client' => new \GuzzleHttp\Client(['handler' => $handlerStack]),
      ]);
      
  • Queue Integration:
    • Wrap Intercom calls in Laravel queues for async processing:
      class UpdateIntercomContact implements ShouldQueue
      {
          public function handle() {
              $client->contacts->update($contactId, $data);
          }
      }
      

Migration Path

  1. Assessment Phase:
    • Audit existing Intercom usage (e.g., Intercom\Legacy\... calls).
    • Identify high-risk endpoints (e.g., critical paths like contact creation).
  2. Dual SDK Phase:
    • Use both SDKs in parallel (new for feature development, legacy for maintenance):
      $newClient = new IntercomClient(config('intercom.token'));
      $legacyClient = new \Intercom\Legacy\IntercomClient(config('intercom.token'));
      
    • Gradually replace legacy calls with new SDK methods (e.g., contacts->update()).
  3. Feature Flagging:
    • Route traffic between SDKs via feature flags (e.g., config('intercom.use_new_sdk')).
  4. Deprecation:
    • Remove legacy SDK dependencies once all critical paths are migrated.
    • Update CI/CD to fail on legacy SDK usage (e.g., composer require intercom/intercom-php:^5.1.0).

Compatibility

  • PHP Versions:
    • Target PHP 8.1+ for full feature support. Use composer require php:^8.1 and polyfills for older versions.
  • Laravel Versions:
    • Compatible with Laravel 9+ (PHP 8.0+) and 10+ (PHP 8.1+). Test with Laravel’s latest LTS.
  • Dependency Conflicts:
    • Resolve conflicts via composer.json:
      "conflict": {
          "guzzlehttp/guzzle": ">=7.0,<8.0"
      },
      "replace": {
          "php-http/httplug": "self.version"
      }
      

Sequencing

  1. Core Integration:
    • Implement basic CRUD operations (e.g., contacts->create(), companies->list()).
    • Test with Laravel’s HTTP tests (Http::fake()).
  2. Advanced Features:
    • Add pagination handlers (e.g., foreach ($contacts as $contact)).
    • Configure retries/timeouts globally (e.g., in AppServiceProvider).
  3. Async Workflows:
    • Queue non-blocking operations (e.g., bulk contact updates).
  4. Monitoring:
    • Instrument with Laravel Scout or custom metrics (e.g., intercom.api.latency).
  5. Rollback Plan:
    • Maintain legacy SDK as a fallback during migration.

Operational Impact

Maintenance

  • Pros:
    • Automated Retries: Reduces flaky API failures (e.g., 429s).
    • Type Safety: Catches errors early (e.g., invalid request payloads).
    • Pagination: Simplifies large dataset handling.
  • Cons:
    • Generated Code: Limited ability to extend/modify SDK (e.g., adding custom endpoints).
    • Dependency Updates: Requires vigilance for Intercom API changes (e.g., breaking changes in v2.0).
    • Token Management: Manual rotation of Intercom tokens may be needed (integrate with Laravel’s env() or Hashicorp Vault).

Support

  • Debugging:
    • Use Laravel’s dd() or Log::debug() to inspect IntercomApiException payloads:
      catch (Inter
      
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky