定制 enlivy/enlivy-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

enlivy/enlivy-php

最新稳定版本:0.1.0

Composer 安装命令:

composer require enlivy/enlivy-php

包简介

Official PHP client library for the Enlivy API

README 文档

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

统计信息

  • 总下载量: 141
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固