
Check out BoldSign at the Singapore Business Show, booth 716, on August 30 - 31! Learn More
Check out BoldSign at the Singapore Business Show, booth 716, on August 30 - 31! Learn More
By integrating eSignatures into your PHP Laravel application, you can seamlessly perform the entire electronic signature processes within your app. This provides enhanced flexibility for both you and your users, enabling to send, sign, track, download, and perform other eSignature actions directly within your application. This streamlined approach eliminates the need for third-party platforms, offering greater convenience and instilling trust and confidence in your users regarding the documents they are signing.
In this blog post, we will guide you on how to integrate the BoldSign eSignature solution into your PHP Laravel application using its APIs. BoldSign’s eSignature solution offers numerous advantages, including quick and seamless integration, maintaining brand consistency, ensuring document security, and providing compliance with legal requirements, among other benefits.
To illustrate the benefits of integration, let’s consider a real-life situation where a company welcomes a new employee to its workforce. To safeguard sensitive company information and ensure confidentiality, it is crucial for the employee to sign a non-disclosure agreement (NDA). By integrating eSignatures into its PHP application, the company can facilitate the entire eSignature process directly within their own application. This streamlined approach guarantees a seamless and efficient experience for the employees
Before you begin integrating eSignatures into your PHP Laravel application, there are a few prerequisites to consider. These include having a BoldSign account, obtaining an API key, and ensuring that PHP, Composer, and Laravel are installed on your machine.
Once you have your account, you will also need an API key to authenticate your access. This can be generated from the API Key – BoldSign page.
You can either use an existing PHP Laravel project or create a new one by following the steps we’ll mention. To create a Laravel project, you need to have PHP, Composer, and Laravel installed on your machine.
Composer global require laravel/installer
With Laravel installed, create a new Laravel project to integrate the eSignature solution:
laravel new project-name
To configure the environment for your BoldSign integration, follow these steps:
BOLDSIGN_API_KEY=<Your API Key>
Now it’s time to start the local development server and see your Laravel application in action:
php artisan serve
By following these steps, you have successfully set up a new PHP Laravel application with BoldSign integration.
BoldSign offers multiple methods to create and send signature requests. You can either create signature requests directly using the API, by utilizing templates, or embed the “create signature request” UI in your application.
In this case, let’s create a signature request using templates. A new template can be created using BoldSign APIs or through the BoldSign web application. The template should include all the necessary elements for the “new employee NDA” scenario.
Once the template is created, make a note of the template ID, which will be used in your PHP code for sending the document for signing.
With all the necessary steps completed, you are now set to integrate the eSignature process within your PHP application. Let’s integrate the following eSignature functionalities:
To initiate the signing process, you can make use of the BoldSign send API. In your Laravel controller, add the necessary code to send a signature request to the employee using the obtained template ID. Here is an example code snippet that demonstrates this functionality.
public function createDocumentFromTemplate(Request $request)
{
$templateId = "***Your Template Id***";
$employeeName = $request->input('name');
$employeeEmail = $request->input('email');
$templateDetails = [
"roles" => [
[
"roleIndex" => 1,
"signerName" => $employeeName,
"signerEmail" => $employeeEmail,
]
]
];
$templateAPIUrl = "https://api.boldsign.com/v1/template/send/?templateId=" . $templateId;
$headers = ['X-API-Key' => env('BOLDSIGN_API_KEY')];
$client = new Client(['verify' => false]);
$request = new GuzzleRequest('POST', $templateAPIUrl, $headers);
$response = $client->send($request, ['json' => $templateDetails]);
return json_decode($response->getBody()->getContents())->documentId;
}
Upon successful creation of the signature request, the response will include the document ID for the created request. This document ID is further required for generating the embedded signing link.
To generate an embedded signing URL, you can make use of the BoldSign getEmbeddedSignLink API. Pass the document ID and the signer’s email address as parameters. This API will generate a URL that can be loaded into an iFrame, ensuring a seamless signing experience for your signers within your application. Refer to the example code snippet below.
public function generateEmbedSignLink($documentId, $email)
{
$queryString = http_build_query([
'DocumentId' => $documentId,
'SignerEmail' => $email,
'RedirectUrl' => "http://localhost:8000/" // You can provide the redirect URL of your choice.
]);
$embedSignAPIUrl = "https://api.boldsign.com/v1/document/getEmbeddedSignLink?" . $queryString;
$headers = ['X-API-Key' => env('BOLDSIGN_API_KEY')];
$client = new Client(['verify' => false]);
$response = $client->request('GET', $embedSignAPIUrl, ['headers' => $headers]);
$signLink = json_decode($response->getBody()->getContents())->signLink;
return json_encode($signLink);
}
The following screenshot shows the signing screen embedded within an application.
To handle the completion of the signing process and redirect the user back to your PHP application, you can utilize the RedirectUrl parameter. This allows you to specify the URL where the user should be redirected after completing the signing process.
After the signing process is successfully completed, using the BoldSign download API, you can download the signed document if you wish to save a copy for further use. The following code snippet illustrates this.
public function downloadDocument($documentId)
{
$downloadDocumentAPIUrl = "https://api.boldsign.com/v1/document/download?documentId=" . $documentId;
$headers = [
'Accept' => 'application/json',
'X-API-Key' => env('BOLDSIGN_API_KEY')
];
$client = new Client(['verify' => false]);
$response = $client->request('GET', $downloadDocumentAPIUrl, ['headers' => $headers]);
if ($response->getStatusCode() == 200) {
$fileContent = $response->getBody()->getContents();
return Response::make($fileContent, 200, [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="document.pdf"'
]);
}
}
Since the document signing is an asynchronous process, it is recommended to listen for the WebHook completed event to ensure that the document is ready to download. Refer to the Webhooks documentation for further details.
We hope this blog has provided you with valuable insights on integrating eSignatures into your PHP Laravel application for the “new employee NDA” scenario. Likewise, you can integrate BoldSign into any other applications where eSigning is required. With a wide range of APIs available, BoldSign allows you to track signature request statuses and access various other functionalities to enhance your eSignature workflows.
To learn more about BoldSign APIs, visit our API documentation. Live API demos are also available for several different scenarios. Sample code for popular programming languages is available in this GitHub repo.
If you have questions, you can contact us through our support portal. We are always happy to assist you!
Ramesh is a passionate Product Manager at BoldSign with 6+ years of hands-on experience in software development. He excels in web technologies, mastering .NET and harnessing Vue.js. His full-stack expertise enables him to deliver innovative solutions. Ramesh thrives in cross-functional teams, driving projects forward with his strategic mindset.
Ramesh is a passionate Product Manager at BoldSign with 6+ years of hands-on experience in software development. He excels in web technologies, mastering .NET and harnessing Vue.js. His full-stack expertise enables him to deliver innovative solutions. Ramesh thrives in cross-functional teams, driving projects forward with his strategic mindset.
Latest Articles
Send eSignature documents from bubble.io using BoldSign
Create Custom Form Fields to Speed Up Document Building with BoldSign
Top 10 Use Cases of eSignatures