PHP Launcher Code Examples
If you downloaded this project using the Quickstart tool, it may be configured in one of three ways:
Installation and running instructions vary depending on the configuration. Follow the link that matches your project type to get started.
This GitHub repo includes code examples for the Web Forms API, Maestro API, Docusign Admin API, Click API, eSignature REST API, Monitor API, and Rooms API.
Introduction
This repo is a PHP application that supports the following authentication workflows:
-
Authentication with Docusign via Authorization Code Grant.
When the token expires, the user is asked to re-authenticate. The refresh token is not used.
-
Authentication with Docusign via JSON Web Token (JWT) Grant.
When the token expires, it updates automatically.
The PHP OAuth 2.0 Client package is used for authentication. This launcher includes a Docusign OAuth2 provider for the OAuth package and a resource owner to process the results of the call to OAuth::getUser.
The OAuth library is used in the file index.php.
eSignature API
For more information about the scopes used for obtaining authorization to use the eSignature API, see Required scopes.
For a list of code examples that use the eSignature API, see the How-to guides overview on the Docusign Developer Center.
Rooms API
Note: To use the Rooms API, you must also create your Rooms developer account. Examples 4 and 6 require that you have the Docusign Forms feature enabled in your Rooms for Real Estate account.
For more information about the scopes used for obtaining authorization to use the Rooms API, see Required scopes.
For a list of code examples that use the Rooms API, see the How-to guides overview on the Docusign Developer Center.
Click API
For more information about the scopes used for obtaining authorization to use the Click API, see Required scopes
For a list of code examples that use the Click API, see the How-to guides overview on the Docusign Developer Center.
Monitor API
Note: To use the Monitor API, you must also enable Docusign Monitor for your organization.
For information about the scopes used for obtaining authorization to use the Monitor API, see the scopes section.
For a list of code examples that use the Monitor API, see the How-to guides overview on the Docusign Developer Center.
Admin API
Note: To use the Admin API, you must create an organization in your Docusign developer account. Also, to run the Docusign CLM code example, CLM must be enabled for your organization.
For information about the scopes used for obtaining authorization to use the Admin API, see the scopes section.
For a list of code examples that use the Admin API, see the How-to guides overview on the Docusign Developer Center.
Web Forms API
The Web Forms API is available in all developer accounts, but only in certain production account plans. Contact Docusign Support or your account manager to find out whether the Web Forms API is available for your production account plan.
For more information about the scopes used for obtaining authorization to use the Rooms API, see Required scopes.
For a list of code examples that use the Web Forms API, see the How-to guides overview on the Docusign Developer Center.
Installation
Prerequisites
Note: If you downloaded this code using Quickstart from the Docusign Developer Center, skip items 1 and 2 below as they were automatically performed for you.
-
A free Docusign developer account; create one if you don't already have one.
-
A Docusign app and integration key that is configured to use either Authorization Code Grant or JWT Grant authentication.
This video demonstrates how to obtain an integration key.
To use Authorization Code Grant, you will need an integration key and a secret key. See Installation steps for details.
To use JWT Grant, you will need an integration key, an RSA key pair, and the User ID GUID of the impersonated user. See Installation steps for JWT Grant authentication for details.
For both authentication flows:
If you use this launcher on your own workstation, the integration key must include redirect a URI of http://localhost:8080/public/index.php?page=ds_callback
If you host this launcher on a remote web server, set your redirect URI as
{base_url}/index.php?page=ds_callback
where {base_url} is the URL for the web app.
-
PHP 8.3.36 or later.
-
Composer set up in your PATH environment variable so you can invoke it from any folder.
Installation steps
Note: If you downloaded this code using Quickstart from the Docusign Developer Center, skip step 4 below as it was automatically performed for you.
- Extract the Quickstart ZIP file or download or clone the code-examples-php repository.
- In your command-line environment, switch to the folder:
cd <Quickstart_folder> or cd code-examples-php
- To install dependencies, run:
composer install
- To configure the launcher for Authorization Code Grant authentication, create a copy of the file ds_config_example.php and save the copy as ds_config.php.
- Add your integration key. On the Apps and Keys page, under Apps and Integration Keys, choose the app to use, then select Actions > Edit. Under General Info, copy the Integration Key GUID and save it in ds_config.php as your
ds_client_id.
- Generate a secret key, if you don’t already have one. Under Authentication, select + ADD SECRET KEY. Copy the secret key and save it in ds_config.php as your
ds_client_secret.
- Add the launcher’s redirect URI. Under Additional settings, select + ADD URI, and set a redirect URI of http://localhost:8080/public/index.php?page=ds_callback. Select SAVE.
- Set a name and email address for the signer. In ds_config.php, save an email address as
signer_email and a name as signer_name.
Note: Protect your personal information. Please make sure that ds_config.php will not be stored in your source code repository.
- Configure your web server to serve the files in the /public folder. For a simple web server setup, see the PHP web server instructions below.
- Open a browser to http://localhost:8080/public.
PHP web server instructions
PHP can be used with the command line to launch a built in web server.
- Extract the Quickstart ZIP file or download or clone the code-examples-php repository.
- In your command-line environment, switch to the folder:
cd <Quickstart_folder> or cd code-examples-php
- To install dependencies, run:
composer install
- To start a built-in PHP web server, run:
php -S localhost:8080
- Open a browser to http://localhost:8080/public.
XAMPP Apache web server instructions
XAMPP Apache web server can be configured to run the PHP launcher.
-
Extract the Quickstart ZIP file or download or clone the code-examples-php repository into your C:/xampp/htdocs folder.
-
In your command-line environment, switch to the folder: cd C:xampp/htdocs/<Quickstart_folder> or cd C:xampp/htdocs/code-examples-php
-
To install dependencies, run: composer install
-
Run XAMPP as administrator. On the XAMPP Control Panel, to the left of Apache, select the red "X" to install Apache web server.