karim-tao / pipedrive-laravel
Laravel integration for the Pipedrive API. Config-driven credentials and Laravel's own HTTP client under the hood.
Requires
- php: ^8.3
- illuminate/http: ^12.0 || ^13.0
- illuminate/support: ^12.0 || ^13.0
- karim-tao/pipedrive-client: ^0.2
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pao: ^1.0
- laravel/pint: ^1.29
- orchestra/testbench: ^10.0
- pestphp/pest: ^4.4
- pestphp/pest-plugin-type-coverage: ^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Talk to the Pipedrive API from Laravel: config-driven app credentials and Laravel's own HTTP client under the hood.
In this example, we build a client from a token stored for a user and read the authorized user:
use Pipedrive\Client\PipedriveClient; use Pipedrive\Laravel\Http\LaravelHttpClient; $pipedrive = PipedriveClient::factory() ->withClientCredentials(config('pipedrive.auth.client_id'), config('pipedrive.auth.client_secret')) ->withToken($accessToken, $expiresAt, $refreshToken, $baseUrl) ->withHttpClient(new LaravelHttpClient) ->make(); $user = $pipedrive->users()->me();
Not using Laravel? See
karim-tao/pipedrive-client.
Installation
Requires PHP 8.3+ and Laravel 12 or 13.
You can install the package via composer:
composer require karim-tao/pipedrive-laravel
The service provider is discovered automatically. Publish the config file if you want to change it:
php artisan vendor:publish --tag=pipedrive-config
Configuration
Set the credentials of your Pipedrive app in .env:
PIPEDRIVE_CLIENT_ID=your-client-id PIPEDRIVE_CLIENT_SECRET=your-client-secret
All options
Everything in config/pipedrive.php:
| Key | Env | Default |
|---|---|---|
auth.client_id |
PIPEDRIVE_CLIENT_ID |
'' |
auth.client_secret |
PIPEDRIVE_CLIENT_SECRET |
'' |
http.timeout |
PIPEDRIVE_HTTP_TIMEOUT |
30 |
http.connect_timeout |
PIPEDRIVE_HTTP_CONNECT_TIMEOUT |
10 |
How it works
Pipedrive tokens belong to each user who connects their company, so there is no shared client: build one per user with PipedriveClient::factory() and pass LaravelHttpClient, a PSR-18 adapter over Laravel's Http facade, so it honours your HTTP config, fakes and middleware.
Pipedrive gives a new refresh token on every refresh. Pass an event dispatcher with withEventDispatcher() to store the new pair as soon as the client dispatches Pipedrive\Client\Events\TokenRefreshed.
Testing
composer test
Because requests go through Laravel's Http facade, Http::fake() works out of the box:
Http::fake([ '*/api/v1/users/me' => Http::response(['success' => true, 'data' => ['id' => 5, 'name' => 'Karim']]), ]);
License
Pipedrive Laravel is open-sourced software licensed under the MIT license.