PHPackages                             azaharizaman/nexus-export - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. azaharizaman/nexus-export

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

azaharizaman/nexus-export
=========================

Framework-agnostic export/output rendering engine for ERP system

v0.1.0-alpha1(1mo ago)02↓100%1MITPHPPHP ^8.3

Since May 5Pushed 1mo agoCompare

[ Source](https://github.com/azaharizaman/nexus-export)[ Packagist](https://packagist.org/packages/azaharizaman/nexus-export)[ RSS](/packages/azaharizaman-nexus-export/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (2)Versions (2)Used By (1)

Nexus\\Export
=============

[](#nexusexport)

**Framework-agnostic export/output rendering engine for converting structured data into downloadable formats.**

Purpose
-------

[](#purpose)

`Nexus\Export` is a stateless, atomic package that transforms domain data from any Nexus package into various output formats (PDF, Excel, CSV, JSON, etc.) through a standardized **ExportDefinition** intermediate representation. The package never knows the source domain (financial statements, payslips, purchase orders) or final usage—it simply converts structured data to the requested format.

This package handles the **"getting data out of the system"** use case, complementing the planned `Nexus\Import` package which will handle the reverse process.

Key Design Principles
---------------------

[](#key-design-principles)

1. **Stateless &amp; Atomic**: Zero state persistence, zero Laravel dependencies in core
2. **Schema-Validated**: All ExportDefinitions validated against versioned schema before processing
3. **Resilient**: Circuit breaker support for external formatters, rate limiting for webhooks
4. **Streaming-Capable**: Memory-efficient processing of large datasets (100K+ rows)
5. **Format-Agnostic**: Domain packages never reference output formats directly

Architecture
------------

[](#architecture)

```
Domain Package (Nexus\Accounting)
    ↓
ExportGeneratorInterface::toExportDefinition()
    ↓
ExportDefinition (validated, versioned JSON structure)
    ↓
ExportManager::export($definition, $format, $destination)
    ↓
ExportFormatterInterface (factory selects: PDF/Excel/CSV/etc.)
    ↓
ExportResult (file_path, success, metadata)
    ↓
ExportDestination (DOWNLOAD/EMAIL/STORAGE/WEBHOOK/PRINTER)

```

Core Components
---------------

[](#core-components)

### Contracts (Public API)

[](#contracts-public-api)

- `ExportGeneratorInterface` - Converts domain data → ExportDefinition
- `ExportFormatterInterface` - Converts ExportDefinition → output format
- `TemplateEngineInterface` - Renders templates with variable substitution
- `ExportStorageInterface` - File persistence
- `ExportRepositoryInterface` - Export history tracking
- `DefinitionValidatorInterface` - Schema validation
- `FormatterCircuitBreakerInterface` - Failure handling for external formatters

### Value Objects

[](#value-objects)

- `ExportDefinition` - Standardized data structure (metadata + structure + styling)
- `ExportMetadata` - Author, timestamp, schema version, watermark, security settings
- `ExportSection` - Hierarchical section with nesting (0-8 levels)
- `TableStructure` - Headers, rows, footers, column widths
- `ExportResult` - Execution result with file path, duration, success status

### Enums

[](#enums)

- `ExportFormat` - PDF, EXCEL, CSV, JSON, XML, HTML, TXT, PRINTER
- `ExportDestination` - DOWNLOAD, EMAIL, STORAGE, PRINTER, WEBHOOK, DOCUMENT\_LIBRARY

### Core Engine (Framework-Agnostic)

[](#core-engine-framework-agnostic)

- `DefinitionValidator` - Validates ExportDefinition against schema v1.0
- `TemplateRenderer` - Variable substitution, conditionals, loops
- `DataTransformer` - Array transformations for different formats
- `CsvFormatter` - Streaming CSV generation using PHP generators
- `JsonFormatter` - UTF-8 JSON with pretty print
- `TxtFormatter` - ASCII tabular format
- `XmlFormatter` - Well-formed XML 1.0

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

[](#installation)

```
composer require azaharizaman/nexus-export:"*@dev"
```

Usage Examples
--------------

[](#usage-examples)

### 1. Generate Financial Statement PDF

[](#1-generate-financial-statement-pdf)

```
use Nexus\Accounting\Services\Export\FinancialStatementExportGenerator;
use Nexus\Export\Services\ExportManager;
use Nexus\Export\ValueObjects\ExportFormat;
use Nexus\Export\ValueObjects\ExportDestination;

// Domain package generates ExportDefinition
$generator = new FinancialStatementExportGenerator($statement);
$definition = $generator->toExportDefinition();

// Export to PDF for download
$result = $exportManager->export(
    $definition,
    ExportFormat::PDF,
    ExportDestination::DOWNLOAD
);

if ($result->isSuccessful()) {
    // Download file at $result->getFilePath()
}
```

### 2. Generate Payslip PDF with Email Delivery

[](#2-generate-payslip-pdf-with-email-delivery)

```
use Nexus\Payroll\Services\Export\PayslipExportGenerator;

$generator = new PayslipExportGenerator($payrollData);
$definition = $generator->toExportDefinition();

// Export with password protection
$definition->getMetadata()->setSecurity([
    'password' => 'employee-ic-number',
    'encryption' => 'AES-256'
]);

$result = $exportManager->export(
    $definition,
    ExportFormat::PDF,
    ExportDestination::EMAIL
);
```

### 3. Stream Large CSV Export

[](#3-stream-large-csv-export)

```
use Nexus\Finance\Services\Export\GeneralLedgerExportGenerator;

$generator = new GeneralLedgerExportGenerator($ledgerData);
$definition = $generator->toExportDefinition();

// Stream for memory efficiency (100K+ rows)
$stream = $exportManager->stream(
    $definition,
    ExportFormat::CSV
);

foreach ($stream as $chunk) {
    echo $chunk; // Output directly to response
}
```

### 4. Export from Template

[](#4-export-from-template)

```
// Use predefined template with runtime data
$result = $exportManager->exportFromTemplate(
    templateId: 'purchase-order-standard',
    data: [
        'vendor' => $vendor,
        'items' => $lineItems,
        'total' => $poTotal
    ],
    format: ExportFormat::PDF,
    destination: ExportDestination::STORAGE
);
```

ExportDefinition Schema (v1.0)
------------------------------

[](#exportdefinition-schema-v10)

```
{
    "schema_version": "1.0",
    "metadata": {
        "title": "Balance Sheet",
        "author": "system",
        "generated_at": "2025-11-19T10:30:00Z",
        "watermark": "CONFIDENTIAL",
        "security": {
            "password": "secret123"
        }
    },
    "structure": [
        {
            "type": "section",
            "name": "Assets",
            "level": 0,
            "items": [
                {
                    "type": "line",
                    "label": "Cash and Cash Equivalents",
                    "value": "1000000.00",
                    "level": 1,
                    "styling": ["bold"]
                }
            ]
        },
        {
            "type": "table",
            "headers": ["Account", "Debit", "Credit", "Balance"],
            "rows": [
                ["1000", "500.00", "0.00", "500.00"],
                ["2000", "0.00", "300.00", "-300.00"]
            ],
            "footers": ["Total", "500.00", "300.00", "200.00"]
        }
    ]
}
```

Integration Points
------------------

[](#integration-points)

### With Nexus Packages

[](#with-nexus-packages)

- **Nexus\\Storage** - File persistence via `ExportStorageInterface`
- **Nexus\\AuditLogger** - Log all export operations
- **Nexus\\Tenant** - Multi-tenancy context
- **Nexus\\Connector** - Rate limiting for webhooks, circuit breakers for external services
- **Nexus\\Notifier** - Email delivery of exports
- **Nexus\\Identity** - User context and RBAC

### With Domain Packages

[](#with-domain-packages)

- **Nexus\\Accounting** - Financial statement exports
- **Nexus\\Payroll** - Payslip PDF generation
- **Nexus\\Receivable** - Invoice PDFs
- **Nexus\\Payable** - Payment advice documents
- **Nexus\\Procurement** - Purchase order printing
- **Nexus\\Hrm** - Employee directory exports

Performance Targets
-------------------

[](#performance-targets)

- **PER-EXP-001**: Export 100K rows to CSV &lt; 30s using streaming (&lt; 50MB memory)
- **PER-EXP-002**: Financial statement PDF generation &lt; 5s for 1K accounts
- **PER-EXP-003**: Definition validation &lt; 100ms
- **PER-EXP-004**: Template rendering &lt; 200ms for 1000 variables

Security Features
-----------------

[](#security-features)

- Password-protected PDFs for sensitive documents
- Watermarking support for draft/confidential documents
- Digital signatures for finalized statements
- Audit trail for all export operations
- Tenant isolation enforcement
- Rate limiting for webhook/email destinations

Roadmap
-------

[](#roadmap)

### Phase 1 (MVP)

[](#phase-1-mvp)

- Core package structure
- ExportDefinition schema v1.0
- Native formatters (CSV, JSON, TXT, XML)
- Definition validator
- Template renderer
- ExportManager orchestration

### Phase 2 (Atomy Integration)

[](#phase-2-atomy-integration)

- PDF formatter (DomPDF)
- Excel formatter (Maatwebsite/Excel)
- HTML formatter (Blade templates)
- Database models &amp; migrations
- Service provider bindings

### Phase 3 (Domain Integration)

[](#phase-3-domain-integration)

- Financial statement generators
- Payslip generators
- Invoice generators
- Purchase order generators

### Phase 4 (Advanced Features)

[](#phase-4-advanced-features)

- Printer destination support
- Webhook formatter with circuit breaker
- Schema versioning (v1.1+)
- Advanced template builder UI

Documentation
-------------

[](#documentation)

### 📚 Complete Documentation

[](#-complete-documentation)

- **[Getting Started Guide](docs/getting-started.md)** - Quick start tutorial with examples
- **[API Reference](docs/api-reference.md)** - Complete API documentation for all interfaces, services, and value objects
- **[Integration Guide](docs/integration-guide.md)** - Laravel, Symfony, and custom PHP integration examples
- **[Basic Usage Examples](docs/examples/basic-usage.php)** - Simple export scenarios (CSV, JSON, XML, invoices, large datasets)
- **[Advanced Usage Examples](docs/examples/advanced-usage.php)** - Template rendering, custom formatters, nested sections, error handling

### 📋 Package Documentation

[](#-package-documentation)

- **[REQUIREMENTS.md](REQUIREMENTS.md)** - Detailed package requirements (42 requirements)
- **[IMPLEMENTATION\_SUMMARY.md](IMPLEMENTATION_SUMMARY.md)** - Implementation tracking and metrics
- **[TEST\_SUITE\_SUMMARY.md](TEST_SUITE_SUMMARY.md)** - Test coverage plan (38 unit + 8 integration tests)
- **[VALUATION\_MATRIX.md](VALUATION_MATRIX.md)** - Package valuation analysis ($121,600 estimated value)
- **[DOCUMENTATION\_COMPLIANCE\_SUMMARY.md](DOCUMENTATION_COMPLIANCE_SUMMARY.md)** - Documentation compliance report

### 🎯 Quick Links

[](#-quick-links)

- **Architecture:** See [IMPLEMENTATION\_SUMMARY.md](IMPLEMENTATION_SUMMARY.md) for ExportDefinition intermediate representation pattern
- **Testing:** See [TEST\_SUITE\_SUMMARY.md](TEST_SUITE_SUMMARY.md) for planned test suite (46 tests)
- **Integration:** See [docs/integration-guide.md](docs/integration-guide.md) for framework integration examples
- **Examples:** See [docs/examples/](docs/examples/) for runnable code examples

---

License
-------

[](#license)

MIT License - See LICENSE file for details

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance93

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 76.6% 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

36d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/117408?v=4)[Azahari Zaman](/maintainers/azaharizaman)[@azaharizaman](https://github.com/azaharizaman)

---

Top Contributors

[![azaharizaman](https://avatars.githubusercontent.com/u/117408?v=4)](https://github.com/azaharizaman "azaharizaman (461 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (139 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/azaharizaman-nexus-export/health.svg)

```
[![Health](https://phpackages.com/badges/azaharizaman-nexus-export/health.svg)](https://phpackages.com/packages/azaharizaman-nexus-export)
```

###  Alternatives

[symfony/lock

Creates and manages locks, a mechanism to provide exclusive access to a shared resource

515135.1M619](/packages/symfony-lock)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[phpro/soap-client

A general purpose SoapClient library

8895.9M52](/packages/phpro-soap-client)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

562565.8k41](/packages/ecotone-ecotone)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

744284.3k34](/packages/civicrm-civicrm-core)[illuminate/broadcasting

The Illuminate Broadcasting package.

7126.9M199](/packages/illuminate-broadcasting)

PHPackages © 2026

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