PHPackages                             docstron/laravel-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. docstron/laravel-sdk

ActiveLibrary[API Development](/categories/api)

docstron/laravel-sdk
====================

Laravel SDK for Docstron API

v1.0.0(5mo ago)243MITPHPPHP ^8.0

Since Nov 28Pushed 5mo agoCompare

[ Source](https://github.com/playiiit/docstron-laravel-sdk)[ Packagist](https://packagist.org/packages/docstron/laravel-sdk)[ RSS](/packages/docstron-laravel-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (3)Used By (0)

 [![](https://camo.githubusercontent.com/ace2a8da7a39938d4ca7135538cd42b5cfc0430652d02448355b24ead2063a80/68747470733a2f2f646f637374726f6e2e636f6d2f696d616765732f706e672f646f637374726f6e2d6c6f676f2e706e67)](https://camo.githubusercontent.com/ace2a8da7a39938d4ca7135538cd42b5cfc0430652d02448355b24ead2063a80/68747470733a2f2f646f637374726f6e2e636f6d2f696d616765732f706e672f646f637374726f6e2d6c6f676f2e706e67) Docstron Laravel SDK
======================

[](#----docstron-laravel-sdk--)

A Laravel SDK for the Docstron API, allowing you to easily generate PDFs, manage templates, applications, documents, and track usage statistics.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require docstron/laravel-sdk
```

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --tag=docstron-config
```

Add your API key to your `.env` file:

```
DOCSTRON_API_KEY=your-api-key
DOCSTRON_BASE_URL=https://api.docstron.com/v1
```

Usage
-----

[](#usage)

### Applications

[](#applications)

```
use Docstron\Laravel\Facades\Docstron;

// Get all applications
$apps = Docstron::getApplications();

// Get a specific application
$app = Docstron::getApplication('app-7b4d78fb-820c-4ca9-84cc-46953f211234');
```

### Usage Statistics

[](#usage-statistics)

```
use Docstron\Laravel\Facades\Docstron;

// Get usage statistics and limits
$usage = Docstron::getUsage();

// Response includes:
// - applications (total, limit, usage_percentage)
// - templates (total, limit, usage_percentage)
// - documents (total, monthly, usage, monthly_limit, usage_percentage)
// - subscription (plan_name, api_rate_limit, processing_priority, support_level)
```

### Templates

[](#templates)

```
use Docstron\Laravel\Facades\Docstron;

// Get all templates
$templates = Docstron::getTemplates();

// Create a template
$template = Docstron::createTemplate([
    'application_id' => 'app-7b4d78fb-820c-4ca9-84cc-46953f211234',
    'name' => 'Invoice Template',
    'content' => 'Invoice for {{ customer_name }}Amount: {{ amount }}',
    'is_active' => true,
    'extra_css' => '@page { margin: 3cm; }', // Optional
]);

// Get a specific template
$template = Docstron::getTemplate('template-c2465c0b-fc54-4672-b9ac-7446886cd6de');

// Update a template
$template = Docstron::updateTemplate('template-c2465c0b-fc54-4672-b9ac-7446886cd6de', [
    'name' => 'Updated Invoice Template',
    'is_active' => false,
]);

// Delete a template
Docstron::deleteTemplate('template-c2465c0b-fc54-4672-b9ac-7446886cd6de');
```

### Documents

[](#documents)

#### Generate Document

[](#generate-document)

```
use Docstron\Laravel\Facades\Docstron;

// Generate a document with direct PDF response
$pdfContent = Docstron::generateDocument([
    'template_id' => 'template-c2465c0b-fc54-4672-b9ac-7446886cd6de',
    'data' => [
        'customer_name' => 'John Doe',
        'amount' => '$299.00',
    ],
    'response_type' => 'pdf', // Default
]);

// Save the PDF to file
file_put_contents('invoice.pdf', $pdfContent);

// Generate with Base64 response
$response = Docstron::generateDocument([
    'template_id' => 'template-c2465c0b-fc54-4672-b9ac-7446886cd6de',
    'data' => [
        'customer_name' => 'John Doe',
        'amount' => '$299.00',
    ],
    'response_type' => 'json_with_base64',
]);

// Generate with Document ID response
$response = Docstron::generateDocument([
    'template_id' => 'template-c2465c0b-fc54-4672-b9ac-7446886cd6de',
    'data' => [
        'customer_name' => 'John Doe',
        'amount' => '$299.00',
    ],
    'response_type' => 'document_id',
]);

// Generate password-protected PDF
$pdfContent = Docstron::generateDocument([
    'template_id' => 'template-c2465c0b-fc54-4672-b9ac-7446886cd6de',
    'data' => [
        'customer_name' => 'John Doe',
        'amount' => '$299.00',
    ],
    'response_type' => 'pdf',
    'password' => 'SecureDoc2025!',
]);
```

#### Quick Generate Document

[](#quick-generate-document)

```
use Docstron\Laravel\Facades\Docstron;

// Quick generate without pre-creating a template
$pdfContent = Docstron::quickGenerateDocument([
    'html_content' => 'Hello {{ name }}Welcome to Docstron!',
    'data' => [
        'name' => 'John Doe',
    ],
    'response_type' => 'pdf',
]);

// Quick generate with custom CSS
$pdfContent = Docstron::quickGenerateDocument([
    'html_content' => 'Invoice',
    'extra_css' => '@page { margin: 2cm; }',
    'response_type' => 'pdf',
]);

// Quick generate and save as template
$response = Docstron::quickGenerateDocument([
    'html_content' => 'Receipt',
    'save_as_template' => true,
    'template_name' => 'Receipt Template',
    'application_id' => 'app-7b4d78fb-820c-4ca9-84cc-46953f211234',
    'response_type' => 'document_id',
]);
```

#### Manage Documents

[](#manage-documents)

```
use Docstron\Laravel\Facades\Docstron;

// Get all documents
$documents = Docstron::getDocuments();

// Get a specific document
$document = Docstron::getDocument('document-489a79af-8680-4a08-a777-df52f26f296f');

// Download a document
$pdfContent = Docstron::downloadDocument('document-489a79af-8680-4a08-a777-df52f26f296f');
file_put_contents('downloaded.pdf', $pdfContent);

// Update a document
$document = Docstron::updateDocument('document-489a79af-8680-4a08-a777-df52f26f296f', [
    'attributes' => [
        'customer_name' => 'Jane Doe',
        'amount' => '$399.00',
    ],
]);

// Delete a document
Docstron::deleteDocument('document-489a79af-8680-4a08-a777-df52f26f296f');
```

Response Types
--------------

[](#response-types)

When generating documents, you can specify different response types:

- **`pdf`** (default): Returns the PDF file content directly as binary data
- **`json_with_base64`**: Returns JSON with the PDF encoded as base64
- **`document_id`**: Returns JSON with the document ID for later retrieval

Error Handling
--------------

[](#error-handling)

The SDK throws `GuzzleException` for HTTP errors. You should wrap your calls in try-catch blocks:

```
use GuzzleHttp\Exception\GuzzleException;
use Docstron\Laravel\Facades\Docstron;

try {
    $pdf = Docstron::generateDocument([
        'template_id' => 'template-id',
        'data' => ['name' => 'John'],
    ]);
} catch (GuzzleException $e) {
    // Handle error
    logger()->error('Docstron API Error: ' . $e->getMessage());
}
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

Support
-------

[](#support)

- 📚 [Documentation](https://docs.docstron.com)
- 💬 [Issues](https://github.com/playiiit/docstron-python-sdk/issues)
- 📧 Email:

Links
-----

[](#links)

- [Docstron Website](https://docstron.com)
- [API Documentation](https://docs.docstron.com)
- [GitHub Repository](https://github.com/playiiit/docstron-python-sdk)

---

Made with ❤️ by [Playiiit Company](https://playiiit.com)

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance76

Regular maintenance activity

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

162d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c0ef06987cdcade78fde06bc47aeffce096a5f9d3d1e8a077e19c227562e30be?d=identicon)[playiiit](/maintainers/playiiit)

---

Top Contributors

[![playiiit](https://avatars.githubusercontent.com/u/108475294?v=4)](https://github.com/playiiit "playiiit (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/docstron-laravel-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/docstron-laravel-sdk/health.svg)](https://phpackages.com/packages/docstron-laravel-sdk)
```

###  Alternatives

[skagarwal/google-places-api

Google Places Api

1913.0M8](/packages/skagarwal-google-places-api)[dcblogdev/laravel-microsoft-graph

A Laravel Microsoft Graph API (Office365) package

168285.5k1](/packages/dcblogdev-laravel-microsoft-graph)[vluzrmos/slack-api

Wrapper for Slack.com WEB API.

102589.1k3](/packages/vluzrmos-slack-api)[smodav/mpesa

M-Pesa API implementation

16363.7k1](/packages/smodav-mpesa)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1344.8k1](/packages/jasara-php-amzn-selling-partner-api)[grantholle/powerschool-api

A Laravel package to make interacting with PowerSchool less painful.

1715.6k1](/packages/grantholle-powerschool-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
