Download the PHP package devio/pipedrive without Composer
On this page you can find all versions of the php package devio/pipedrive. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
All versions of pipedrive with dependencies
Informations about the package pipedrive
Complete Pipedrive API client for PHP
Contribute by referral code / link
This won't take much time. You could use my referral code or link to get up to 45 days completely free of charge. Just sign up using this link or add the code to the billing section:
Do you like this package? Did you find it useful? Donate and support its development.
This package provides a complete framework agnostic Pipedrive CRM API client library for PHP. It includes all the resources listed on Pipedrive's documentation.
IMPORTANT: If you are using Laravel >= 5.8 make sure your version is > 2.1.0.
Feel free to drop me a message at @IsraelOrtuno.
Quick start using API token (read below for OAuth)
For a deeper knowledge of how to use this package, follow this index:
- Create the Pipedrive instance
- With API token
- With OAuth
- Resolve a Pipedrive API Resource
- Create the Pipedrive instance
- Performing a resource call
- Available methods
- Performing the Request
- Handling the response
- Response methods
- Available resources
- The File Resource
- Configure and use in Laravel
- Service Provider and Facade
- The service configuration
- Using it
Versions 1.x do not include OAuth support, update to version 2.x to use this feature.
You can install the package via
composer require command:
Or simply add it to your composer.json dependences and run
Create the Pipedrive instance
Devio\Pipedrive\Pipedrive class acts as Manager and will be responsible of resolving the different API resources available.
Pipedrive supports two different authentication methods: via API token (for manual integrations) and with OAuth (for public and private apps).
You can read more about it on the official documentation, here: https://pipedrive.readme.io/docs/core-api-concepts-authentication
Using API token
NOTE: Consider storing this object into a global variable.
To understand how the OAuth flow works, please read the documentation first.
You can find it here: https://pipedrive.readme.io/docs/marketplace-oauth-authorization
You will first need to create an app and retrieve client_id and client_secret.
Please, read the official documentation to learn how to do that.
You can find all you need here: https://pipedrive.readme.io/docs/marketplace-creating-a-proper-app
Once you have your client_id, client_secret, and redirect_url, you can instantiate the class like this:
The class will automatically handle the redirect to the authentication server and refresh token requests.
The only thing you need to provide is your own implementation of the PipedriveTokenStorage interface.
The purpose of this class is to read and write a
PipedriveToken object, containing
expiresAt, giving you the ability to handle this information as you prefer (for example storing these properties in your preferred way).
Here's an example of how it can be implemented:
In this simple example, the PipedriveToken is simply stored and retrieved from the session. Which means that once the session expires, the user will be redirected to the authentication page.
You might want to store this object inside the database. Storing the whole object serialized could be the fastest way to do that, but you can also retrieve access token, refresh token, and the expiration time individually using the methods
expiresAt. Like this:
Similarly, the object can be instantiated like so:
Handling the callback
In the callback (the url you specified as
redirectUrl), you should call the
authorize method on the
$pipedrive object, like so:
This will exchange the authorization code for the first access token, and store it using the
setToken method you provided.
Resolve a Pipedrive API Resource
Once we have our Pipedrive instance, we are able to resolve any Pipedrive API Resource in many ways.
First you could do it calling the
It also intercepts the magic method
__get so we could do:
And just in case you prefer
__call, you can use it, too:
They are 3 different ways of doing the same thing, pick the one you like the most. It will automatically set the studly case version of the asked resource, so it will work with
IMPORTANT: Navigate to the
src/Resourcesdirectory to find out all the resources available.
Performing a resource call
All resources have various methods for performing the different API requests. Please, navigate to the resource class you would like to work with to find out all the methods available. Every method is documented and can also be found at Pipedrive API Docs page.
Every resource extends from
Devio\Pipedrive\Resources\Basics\Resource where the most common methods are defined. Some of them are disabled for the resources that do not include them. Do not forget to check out the Traits included and some resources use, they define some other common calls to avoid code duplication.
Performing the Request
After resolved the resource we want to use, we are able to perform an API request. At this point, we only have to execute the endpoint we would like to access:
Any of these methods will perform a synchronous request to the Pipedrive API.
Handling the response
Every Pipedrive API endpoint gives a response and this response is converted to a
Devio\Pipedrive\Http\Response object to handle it:
Response class has many methods available for accessing the response data:
Check if the server responded the request was successful.
Will provide the raw response provided by the Pipedrive API. Useful if you need specific control.
Get the response main data object which will include the information about the endpoint we are calling.
Some responses include an additional data object with some extra information. Fetch this object with this method.
Get the response status code.
Get the response headers.
Every Resource logic is located at the
src/Resources directory. However we'll mention every included resource here:
|Goals||:warning: 5/6||Missing goal results method|
|Pipelines||:warning: 6/8||Missing deals conversion rates and deals movements|
|Roles||:warning: 0/11||Getting unathorized access|
|Users||:warning: 13/20||Getting unathorized access when playing with roles and permissions|
:white_check_mark: Completed / :warning: Pipedrive API errors
The File Resource
The File resource is the only one that works a little bit different than others. While other resources may be intuitively used as most of them just require a plain array of tada, the
File resource requires an
\SplFileInfo instance to make it work:
Actually, it is pretty simple. Just pass a
\SplFileInfo instance to the
file key of the options array and specify at least one of the elements it goes related to (deal, person, ...).
Configure and use in Laravel
If you are using Laravel, you could make use of the
PipedriveFacade which will make the using of this package much more comfortable:
Service Provider and Facade
PipedriveServiceProvider to the providers array in
config/app.php and register the Laravel Facade.
The service configuration
Laravel includes a configuration file for storing external services information at
config/services.php. We have to set up our Pipedrive token at that file like this:
Of course, as many other config parameters, you could store the token at your
.env file or environment variable and fetch it using
You could use it using the Laravel facade
PipedriveFacade that we have previously loaded:
Also, resolve it out of the service container:
Or even inject it wherever you may need using the
Feel free to contribute via PR.