PHPackages                             antonioprimera/contractera-laravel-client - 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. antonioprimera/contractera-laravel-client

ActiveLibrary[API Development](/categories/api)

antonioprimera/contractera-laravel-client
=========================================

Laravel client package for backend-only Contractera integrations.

v0.1.1(1mo ago)050↑40%[1 PRs](https://github.com/AntonioPrimera/contractera-laravel-client/pulls)MITPHPPHP ^8.4CI passing

Since Jun 4Pushed 1mo agoCompare

[ Source](https://github.com/AntonioPrimera/contractera-laravel-client)[ Packagist](https://packagist.org/packages/antonioprimera/contractera-laravel-client)[ Docs](https://github.com/AntonioPrimera/contractera-laravel-client)[ GitHub Sponsors](https://github.com/:vendor_name)[ RSS](/packages/antonioprimera-contractera-laravel-client/feed)WikiDiscussions main Synced 1w ago

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

Contractera Laravel Client
==========================

[](#contractera-laravel-client)

Laravel client package for backend-only Contractera integrations.

The package is meant to be used together with the Vue SDK:

```
npm install @raprim/contractera-plugin-vue3
```

The frontend package renders the UI. This Composer package handles the server-to-server Contractera API calls from a Laravel host application such as AgroCity or ProjectCity.

Browser code must never receive Contractera tokens.

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

[](#installation)

```
composer require antonioprimera/contractera-laravel-client
```

Publish the config:

```
php artisan vendor:publish --tag="contractera-laravel-client-config"
```

Add environment values:

```
CONTRACTERA_BASE_URL=https://contractera.ro
CONTRACTERA_APPLICATION_TOKEN=plain-text-application-token
CONTRACTERA_DEFAULT_PLACEHOLDER_PATTERN=__#__
CONTRACTERA_TIMEOUT=30
CONTRACTERA_RETRY_TIMES=2
CONTRACTERA_RETRY_SLEEP_MILLISECONDS=250
```

Local development usually uses:

```
CONTRACTERA_BASE_URL=https://contractor.test
```

Security model
--------------

[](#security-model)

Contractera uses two token types:

1. `Application token` - stored in the host backend and used for cross-account operations such as provisioning, updating, deleting and regenerating account tokens.
2. `Account token` - issued by Contractera for one Contractera account and used for template/document operations.

The host application must store account tokens encrypted and must proxy all frontend requests through its own backend.

Provision an account
--------------------

[](#provision-an-account)

```
use AntonioPrimera\ContracteraLaravelClient\ContracteraClient;

$contracteraAccount = app(ContracteraClient::class)->provisionAccount(
    externalAccountId: 'agrocity-account-'.$agrocityAccount->id,
    name: $agrocityAccount->name,
);

$agrocityAccount->forceFill([
    'contractera_account_id' => $contracteraAccount->id,
    'contractera_external_account_id' => $contracteraAccount->externalAccountId,
    'contractera_account_token' => $contracteraAccount->accountToken,
])->save();
```

Recommended host model casts:

```
protected function casts(): array
{
    return [
        'contractera_account_token' => 'encrypted',
        'contractera_connected_at' => 'datetime',
        'contractera_disconnected_at' => 'datetime',
    ];
}
```

Application-scoped operations
-----------------------------

[](#application-scoped-operations)

```
$client = app(ContracteraClient::class);

$accounts = $client->listAccounts();

$account = $client->updateAccount($contracteraAccountId, [
    'name' => 'Updated account name',
]);

$account = $client->regenerateAccountToken($contracteraAccountId);

$client->deleteAccount($contracteraAccountId);
```

`deleteAccount()` marks the account for deletion in Contractera and immediately revokes account-scoped tokens.

Account-scoped operations
-------------------------

[](#account-scoped-operations)

Create an account-scoped client from the encrypted token stored in the host application:

```
$accountClient = app(ContracteraClient::class)
    ->forAccountToken($agrocityAccount->contractera_account_token);
```

### List templates

[](#list-templates)

```
$templates = $accountClient->listTemplates();
```

### Upload template

[](#upload-template)

```
$template = $accountClient->uploadTemplate(
    name: 'Contract arenda',
    placeholderPattern: '__#__',
    file: $request->file('file'),
);
```

For a placeholder like `__OWNER_NAME__`, use pattern `__#__`. Contractera exposes key `OWNER_NAME`.

### Placeholder metadata

[](#placeholder-metadata)

```
$placeholders = $accountClient->listPlaceholders($templateId);

$updated = $accountClient->updatePlaceholders($templateId, [
    [
        'key' => 'OWNER_NAME',
        'label' => 'Nume proprietar',
        'input_type' => 'text',
        'required' => true,
        'help_text' => null,
        'display_order' => 1,
        'input_config' => [],
    ],
]);
```

Supported `input_type` values:

```
text
textarea
date
number
email
select
checkbox
rich_text
```

### Validate and preview

[](#validate-and-preview)

```
$preview = $accountClient->validatePreview($templateId, [
    'OWNER_NAME' => 'Ion Popescu',
]);

if ($preview->valid) {
    echo $preview->html;
}
```

The host frontend should allow generation only after Contractera returns a valid preview response.

### Generate document

[](#generate-document)

```
$document = $accountClient->generateDocument(
    templateId: $templateId,
    values: [
        'OWNER_NAME' => 'Ion Popescu',
    ],
    format: 'docx',
);

$document->id;
$document->status;
$document->downloadUrls;
```

### Status and download

[](#status-and-download)

```
$document = $accountClient->generatedDocument($documentId);

$response = $accountClient->downloadDocument($documentId, 'docx');

return response($response->body(), $response->status(), [
    'Content-Type' => $response->header('Content-Type'),
    'Content-Disposition' => $response->header('Content-Disposition'),
]);
```

The host application should expose local download URLs to the browser, not direct Contractera URLs.

Frontend integration
--------------------

[](#frontend-integration)

The Vue SDK receives an adapter implemented by the host frontend. That adapter calls local backend routes, and those local backend routes use this Composer package.

Recommended local routes:

```
GET /contractera/templates
POST /contractera/templates
GET /contractera/templates/{templateId}/placeholders
PATCH /contractera/templates/{templateId}/placeholders
POST /contractera/templates/{templateId}/validate-preview
POST /contractera/templates/{templateId}/generate
GET /contractera/generated-documents/{documentId}
GET /contractera/generated-documents/{documentId}/download?format=docx|pdf|html
```

Host application testing
------------------------

[](#host-application-testing)

After installing this package in a Laravel host application, test both layers:

1. backend proxy tests with `Http::fake()`:
    - provisioning calls use the Application token;
    - template/document calls use the account token;
    - browser responses never contain Contractera tokens;
    - `validate-preview` converts frontend `values` to Contractera `replacements`;
    - generated document URLs returned to the browser are local host URLs;
2. frontend/browser checks with `@raprim/contractera-plugin-vue3`:
    - placeholder metadata loads and saves;
    - live preview updates after debounced form edits;
    - invalid input blocks generation;
    - generated documents download through the host backend;
    - mobile mode uses `mobile-mode="tab"` or another explicit mobile strategy.

The reference integration app is:

```
/Users/antonio/Workspace/workbench/contractera-integrator
```

Its Contractera integration tests are in:

```
tests/Feature/ContracteraIntegrationTest.php
```

Testing
-------

[](#testing)

```
composer test
composer analyse
composer format
```

Compatibility
-------------

[](#compatibility)

Use this package with `@raprim/contractera-plugin-vue3` using the same major version once both packages are versioned.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance92

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

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

Every ~0 days

Total

2

Last Release

51d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/77cac31fc31444fb45ef19e3628a7b243b5456679a9e6db635aa3b979bfdbefc?d=identicon)[AntonioPrimera](/maintainers/AntonioPrimera)

---

Top Contributors

[![AntonioPrimera](https://avatars.githubusercontent.com/u/23128666?v=4)](https://github.com/AntonioPrimera "AntonioPrimera (3 commits)")

---

Tags

clientlaraveldocumentscontractera

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/antonioprimera-contractera-laravel-client/health.svg)

```
[![Health](https://phpackages.com/badges/antonioprimera-contractera-laravel-client/health.svg)](https://phpackages.com/packages/antonioprimera-contractera-laravel-client)
```

###  Alternatives

[defstudio/telegraph

A laravel facade to interact with Telegram Bots

813336.8k3](/packages/defstudio-telegraph)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.6k](/packages/simplestats-io-laravel-client)[api-platform/laravel

API Platform support for Laravel

58174.6k17](/packages/api-platform-laravel)[masterix21/laravel-licensing

Laravel licensing package with polymorphic assignment to any model, activation keys, expirations/renewals, and seat control via LicenseUsage. Supports offline verification with public-key–signed tokens, a CLI to generate/rotate/revoke keys, and an extensible architecture via config and contracts.

1613.3k4](/packages/masterix21-laravel-licensing)

PHPackages © 2026

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