- How do I install docusign/esign-client in a Laravel project?
- Run `composer require docusign/esign-client` in your project root. Laravel’s PSR-4 autoloader will handle the rest—no manual includes needed. Ensure your project uses PHP 7.4+ for compatibility with the SDK’s latest version (8.8.1).
- Which Laravel versions does this package support?
- The package works with Laravel 8.0+ (PHP 7.4+) and Laravel 10+ (PHP 8.1+). For Laravel 10, upgrade to SDK v8.8.1+ to avoid PHP 7.4 deprecation risks. Test thoroughly if using older Laravel versions with PHP 8.x.
- Can I use this SDK with Laravel’s queue system for async envelope sending?
- Yes. Wrap DocuSign API calls in Laravel jobs (e.g., `SendEnvelopeJob`) to offload heavy operations like bulk envelope creation. The SDK’s non-blocking API calls integrate perfectly with Laravel’s queue workers or Horizon for background processing.
- How should I handle OAuth2 authentication in Laravel?
- Use Laravel’s session for redirect flows and store tokens in cache (e.g., `cache()->put('docusign_token', $token, now()->addHours(1))`) or a database. For SPAs, implement PKCE. Libraries like `league/oauth2-client` can simplify OAuth2 flows if needed.
- What’s the best way to manage DocuSign API errors in Laravel?
- Extend Laravel’s exception handler to catch DocuSign-specific errors (e.g., `429 Too Many Requests` or `401 Unauthorized`). Create a custom `DocuSignException` class to wrap SDK errors and log them via Laravel’s logging system for debugging.
- Do I need to handle webhook events from DocuSign in Laravel?
- Yes, if you need real-time updates (e.g., `envelope_sent` or `document_signed`). Use Laravel’s queue workers or Horizon to process webhook payloads asynchronously. Validate webhook signatures using DocuSign’s provided tools to ensure security.
- Where should I store signed PDFs generated by DocuSign?
- Use Laravel’s filesystem (e.g., `storage/app/public` or S3 via `spatie/laravel-medialibrary`) to store signed PDFs. For scalability, pair with a dedicated service like AWS S3 or DigitalOcean Spaces, and index metadata in Laravel’s database.
- How do I integrate this SDK with Laravel’s service container?
- Create a `DocuSignServiceProvider` to bind the SDK as a singleton. Register configurations (e.g., API credentials, OAuth settings) in `config/services.php` and bind the client to the container using `bind(Client::class, function ($app) { return new Client(...); })`.
- Are there alternatives to this SDK for Laravel eSignature workflows?
- Alternatives include `paddle/paddle-php` (for Paddle’s eSignature) or building a custom wrapper around DocuSign’s REST API. However, `docusign/esign-client` is the official, battle-tested SDK with Laravel-friendly features like OAuth2 support and async capabilities.
- How do I test DocuSign integrations in Laravel?
- Use DocuSign’s sandbox environment for testing. Mock the SDK in unit tests with Laravel’s `Mockery` or `PHPUnit`. For integration tests, use Laravel’s HTTP tests to simulate API calls and verify responses. Test token refresh flows and error scenarios separately.