enlivy/enlivy-php

Official PHP client library for the Enlivy API

Maintainers

Package info

github.com/enlivy/enlivy-php

Homepage

pkg:composer/enlivy/enlivy-php

Statistics

Installs: 136

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.1.0 2026-04-09 19:16 UTC

This package is auto-updated.

Last update: 2026-04-09 19:17:22 UTC


README

Official PHP client library for the Enlivy API.

Requirements

  • PHP 8.3+
  • ext-curl, ext-json, ext-mbstring

Installation

composer require enlivy/enlivy-php

Quick Start

$client = new \Enlivy\EnlivyClient([
    'api_key' => '1|your_api_token',
    'organization_id' => 'org_xxx',
]);

// List invoices
$invoices = $client->invoices->list(['per_page' => 25]);

foreach ($invoices as $invoice) {
    echo $invoice->id . "\n";
}

// Create
$invoice = $client->invoices->create([
    'organization_receiver_user_id' => 'org_user_xxx',
    'status' => 'draft',
    'currency' => 'EUR',
    'payment_method' => 'bank_transfer',
    'delivery_method' => 'email',
    'line_items' => [
        [
            'name_lang_map' => ['en' => 'Consulting Services'],
            'quantity' => 10,
            'price' => 100.00,
            'type' => 'service',
        ],
    ],
]);

// Retrieve with related data
$invoice = $client->invoices->retrieve('org_inv_xxx', [
    'include' => ['sender_user', 'receiver_user', 'line_items'],
]);

// Update
$client->invoices->update('org_inv_xxx', ['status' => 'pending']);

// Delete
$client->invoices->delete('org_inv_xxx');

Configuration

// Per-client configuration
$client = new \Enlivy\EnlivyClient([
    'api_key' => '1|your_token',
    'organization_id' => 'org_xxx',
    'api_base' => 'https://api.enlivy.com',
    'timeout' => 30,
]);

// Or global configuration
\Enlivy\Enlivy::setApiKey('1|your_token');
\Enlivy\Enlivy::setOrganizationId('org_xxx');
$client = new \Enlivy\EnlivyClient();

Documentation

Detailed guides with code examples for every feature:

Getting Started

Guide Description
Authentication API keys, OAuth client credentials, global config
OAuth Server OAuth 2.0 server for third-party app integrations
Includes (Eager Loading) Load related resources in a single request
Filters Search, sort, paginate, and filter list endpoints

Billing & Invoicing

Guide Description
Invoices Create, send, and manage invoices
Receipts Receipt management and tracking
Billing Packages Reusable billing templates with payment plans
Proposals Send proposals to prospects and customers
Products Product and service catalog
Taxes Tax classes, rates, and filing jurisdictions

CRM & Sales

Guide Description
Prospects Sales pipeline, lead tracking, and CRM
Organization Users Customers, employees, and roles
Projects Projects, team members, and permissions

Contracts

Guide Description
Contracts Contract management, e-signatures, and templates

Banking

Guide Description
Bank Accounts Bank accounts, transactions, and reconciliation

Content & Reports

Guide Description
Reports Dynamic reports with custom schemas
Files File uploads and attachments

Integrations

Guide Description
Webhooks Real-time event notifications and signature verification
Customer Portal Client-facing portal for invoices, contracts, and proposals
Integrations Stripe, ANAF, and other third-party services
AI Agents AI-powered automation

Error Handling

use Enlivy\Exception\{
    ValidationException,
    NotFoundException,
    AuthenticationException,
    RateLimitException,
};

try {
    $invoice = $client->invoices->retrieve('org_inv_xxx');
} catch (ValidationException $e) {
    $errors = $e->errors(); // ['field' => ['error message']]
} catch (NotFoundException $e) {
    // 404
} catch (AuthenticationException $e) {
    // 401
} catch (RateLimitException $e) {
    $retryAfter = $e->retryAfter(); // seconds
}

Pagination

$invoices = $client->invoices->list(['page' => 1, 'per_page' => 25]);

echo "Page " . $invoices->getCurrentPage() . " of " . $invoices->getTotalPages();

foreach ($invoices as $invoice) {
    echo $invoice->id;
}

API Discovery

The SDK includes a discovery service for programmatic API introspection:

// List all available API resources
$resources = $client->discovery->list();

// Get detailed metadata for a specific resource
$invoiceSpec = $client->discovery->resource('organization_invoices');

Key Concepts

Multilingual Fields

Most text fields use _lang_map for multilingual support:

'name_lang_map' => [
    'en' => 'Consulting Services',
    'ro' => 'Servicii de Consultanta',
],

ID Prefixes

All IDs use prefixes to identify the resource type:

Prefix Resource
org_ Organization
org_user_ Organization User
org_inv_ Invoice
org_cont_ Contract
org_pros_ Prospect
org_proj_ Project
org_prod_ Product
org_prop_ Proposal

Testing

./vendor/bin/phpunit              # Unit tests
./vendor/bin/phpstan analyse      # Static analysis

License

MIT License. See LICENSE for details.

Support