PHPackages                             nodus-it/lexware-office-api - 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. nodus-it/lexware-office-api

ActiveLibrary[API Development](/categories/api)

nodus-it/lexware-office-api
===========================

PHP API Client for lexware office

11PHPCI failing

Since Nov 6Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/nodus-it/lexware-office-api)[ Packagist](https://packagist.org/packages/nodus-it/lexware-office-api)[ RSS](/packages/nodus-it-lexware-office-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Lexware Office API Package
==========================

[](#lexware-office-api-package)

[![Tests](https://github.com/nodus-it/lexware-office-api/workflows/Tests/badge.svg)](https://github.com/nodus-it/lexware-office-api/actions/workflows/tests.yml)[![Coverage](https://github.com/nodus-it/lexware-office-api/workflows/Coverage/badge.svg)](https://github.com/nodus-it/lexware-office-api/actions/workflows/coverage.yml)[![License](https://camo.githubusercontent.com/314edca518d01fb7a3cddde172e5b7c83d6e6dce6a1427c3987a860f7446afa3/68747470733a2f2f706f7365722e707567782e6f72672f6e6f6475732d69742f6c6578776172652d6f66666963652d6170692f6c6963656e7365)](https://packagist.org/packages/nodus-it/lexware-office-api)[![Latest Stable Version](https://camo.githubusercontent.com/722ab68d22480dfbbefdf1a783142125ff38a6117c7db09808d1a51a6889fc2a/68747470733a2f2f706f7365722e707567782e6f72672f6e6f6475732d69742f6c6578776172652d6f66666963652d6170692f762f737461626c65)](https://packagist.org/packages/nodus-it/lexware-office-api)[![Total Downloads](https://camo.githubusercontent.com/4c895e4caa4d4fdcc3bc99770ee8a54bdb0459458101b32b0d2818c7f2390d16/68747470733a2f2f706f7365722e707567782e6f72672f6e6f6475732d69742f6c6578776172652d6f66666963652d6170692f646f776e6c6f616473)](https://packagist.org/packages/nodus-it/lexware-office-api)[![PHP Version Require](https://camo.githubusercontent.com/945af96d8ef7e4514109f864ce9b0d5f367059c5078195352838d1a4e99444bb/68747470733a2f2f706f7365722e707567782e6f72672f6e6f6475732d69742f6c6578776172652d6f66666963652d6170692f726571756972652f706870)](https://packagist.org/packages/nodus-it/lexware-office-api)

A comprehensive PHP package for interacting with the Lexware Office API, built on top of the powerful Saloon HTTP client. This package provides a clean, object-oriented interface for managing articles, contacts, invoices, and other entities in Lexware Office.

Features
--------

[](#features)

- 🚀 **Modern Architecture**: Built with PHP 8.1+ features and best practices
- 🔧 **Extensible Design**: Easy to add new API endpoints and entities
- 📊 **Comprehensive Data Handling**: Type-safe data objects with validation
- 🔄 **Automatic Pagination**: Built-in support for paginated API responses
- ⚡ **Rate Limiting**: Automatic rate limiting to comply with API limits
- 🧪 **Testing Support**: Comprehensive testing utilities and mock responses
- 📝 **Rich Documentation**: Extensive PHPDoc and inline documentation
- 🛡️ **Error Handling**: Centralized exception handling with detailed error information

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

[](#installation)

You can install the package via composer:

```
composer require nodus-it/lexware-office-api
```

You can publish the config file with:

```
php artisan vendor:publish --tag="lexware-office"
```

Set your API token in your `.env` file (available at ):

```
LEXWARE_OFFICE_API_TOKEN=your-token-here
```

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

[](#configuration)

The package provides the following configuration options:

```
# Authentication
LEXWARE_OFFICE_API_TOKEN=your-token-here

# API timeouts
LEXWARE_OFFICE_CONNECT_TIMEOUT=30
LEXWARE_OFFICE_REQUEST_TIMEOUT=30

# Rate limiting
# Cache store used by the rate limiter (Laravel cache store name)
LEXWARE_OFFICE_RATE_LIMIT_STORE=file
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use Nodus\LexwareOfficeApi\Utils\LexwareOfficeConnector;
use Nodus\LexwareOfficeApi\Resources\ArticleResource;

// Create connector
$connector = new LexwareOfficeConnector();

// Create resource
$articles = new ArticleResource($connector);

// Get all articles
$allArticles = $articles->all();

// Get specific article
$article = $articles->get('article-id');

// Create new article
$newArticle = $articles->create(ArticleData::from([
    'title' => 'New Product',
    'articleNumber' => 'PROD-001',
    'description' => 'Product description',
    'unitName' => 'Stück',
    'price' => [
        'currency' => 'EUR',
        'netAmount' => 19.99,
        'grossAmount' => 23.79,
        'taxRatePercentage' => 19.0,
    ],
]));
```

### Using the Resource Factory

[](#using-the-resource-factory)

```
use Nodus\LexwareOfficeApi\Utils\ResourceFactory;
use Nodus\LexwareOfficeApi\Utils\LexwareOfficeConnector;

$connector = new LexwareOfficeConnector();

// Create resources using factory
$articles = ResourceFactory::create('articles', $connector);
$contacts = ResourceFactory::create('contacts', $connector);
$invoices = ResourceFactory::create('invoices', $connector);
```

### Advanced Filtering

[](#advanced-filtering)

```
use Nodus\LexwareOfficeApi\Data\Enums\ArticleType;

// Filter articles by type
$serviceArticles = $articles->findByType(ArticleType::SERVICE);

// Filter by article number
$specificArticles = $articles->findByArticleNumber('PROD-001');

// Filter by GTIN
$gtinArticles = $articles->findByGtin('1234567890123');

// Complex filtering
$filteredArticles = $articles->all(
    filterType: ArticleType::PRODUCT,
    filterArticleNumber: 'PROD-*'
);
```

### Error Handling

[](#error-handling)

```
use Nodus\LexwareOfficeApi\Exceptions\LexwareOfficeException;

try {
    $article = $articles->get('non-existent-id');
} catch (LexwareOfficeException $e) {
    if ($e->isValidationError()) {
        $errors = $e->getValidationErrors();
        // Handle validation errors
    } elseif ($e->isClientError()) {
        // Handle client errors (4xx)
    } elseif ($e->isServerError()) {
        // Handle server errors (5xx)
    }

    echo "Error: " . $e->getMessage();
    echo "Status: " . $e->getStatusCode();
}
```

### Pagination

[](#pagination)

```
// Iterate through all pages
foreach ($articles->all() as $article) {
    echo $article->title . "\n";
}

// Manual pagination
$paginator = $articles->all();
$firstPage = $paginator->items(); // Get items from first page

if ($paginator->hasNextPage()) {
    $nextPage = $paginator->nextPage();
}
```

Testing
-------

[](#testing)

The package includes comprehensive testing utilities:

```
use Nodus\LexwareOfficeApi\Tests\LexwareOfficeTestCase;

class ArticleTest extends LexwareOfficeTestCase
{
    public function test_can_get_article()
    {
        // Mock successful response
        $this->mockClient->addResponse(
            $this->mockSuccessResponse($this->getSampleArticleData())
        );

        $articles = new ArticleResource($this->connector);
        $article = $articles->get('article-123');

        $this->assertEquals('Sample Article', $article->title);
        $this->assertRequestSent('GET', 'articles/article-123');
    }

    public function test_handles_validation_errors()
    {
        $this->mockClient->addResponse(
            $this->mockValidationErrorResponse([
                'title' => ['Title is required']
            ])
        );

        $this->expectException(LexwareOfficeException::class);

        $articles = new ArticleResource($this->connector);
        $articles->create(ArticleData::from([]));
    }
}
```

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

[](#architecture)

### Base Classes

[](#base-classes)

- **BaseResource**: Template pattern for all API resources
- **BaseRequest**: Abstract base for all API requests with common functionality
- **BaseData**: Enhanced data objects with validation and transformation
- **LexwareOfficeException**: Centralized error handling

### Request Types

[](#request-types)

- **BaseGetRequest**: For retrieving single entities
- **BaseListRequest**: For retrieving collections with pagination
- **BaseCreateRequest**: For creating new entities
- **BaseUpdateRequest**: For updating existing entities
- **BaseDeleteRequest**: For deleting entities

### Data Traits

[](#data-traits)

- **HasTimestamps**: Adds created/updated timestamp handling
- **HasVersioning**: Adds version control for optimistic locking

Extending the Package
---------------------

[](#extending-the-package)

### Adding New Resources

[](#adding-new-resources)

1. Create a new resource class extending `BaseResource`:

```
class ContactResource extends BaseResource
{
    protected function getEndpoint(): string
    {
        return 'contacts';
    }

    protected function getRequestNamespace(): string
    {
        return 'Nodus\\LexwareOfficeApi\\Requests\\Contacts';
    }

    protected function getDataClass(): string
    {
        return ContactData::class;
    }
}
```

2. Register the resource in the factory:

```
ResourceFactory::register('contacts', ContactResource::class);
```

### Creating Request Classes

[](#creating-request-classes)

```
class GetContactRequest extends BaseGetRequest
{
    protected function resolveEndpoint(): string
    {
        return "contacts/{$this->id}";
    }
}
```

### Creating Data Classes

[](#creating-data-classes)

```
class ContactData extends BaseData
{
    use HasTimestamps;
    use HasVersioning;

    public string $id;
    public ?string $organizationName;
    public ?PersonData $person;
    public ?AddressData $addresses;
}
```

API Coverage
------------

[](#api-coverage)

Currently implemented:

- ✅ Articles (complete)

Planned:

- 🔄 Contacts
- 🔄 Invoices
- 🔄 Vouchers
- 🔄 Quotations
- 🔄 Credit Notes
- 🔄 Order Confirmations
- 🔄 Delivery Notes
- 🔄 Recurring Templates
- 🔄 Payment Conditions
- 🔄 Countries
- 🔄 Files
- 🔄 Profile
- 🔄 Event Subscriptions

Development &amp; Testing
-------------------------

[](#development--testing)

This package uses GitHub Actions for continuous integration and testing:

### Automated Testing

[](#automated-testing)

- **Multi-PHP Version Testing**: Tests run on PHP 8.1, 8.2, and 8.3
- **Dependency Matrix**: Tests with both `prefer-lowest` and `prefer-stable` dependencies
- **Code Coverage**: Comprehensive coverage reporting with Codecov integration
- **Code Quality**: Automated checks with PHPCS, PHPStan, and PHPMD
- **Security Audits**: Regular dependency vulnerability scanning

### Running Tests Locally

[](#running-tests-locally)

```
# Install dependencies
composer install

# Run tests
vendor/bin/phpunit

# Run tests with coverage
vendor/bin/phpunit --coverage-html coverage

# Run code quality checks (if tools are installed)
vendor/bin/phpcs --standard=PSR12 src/ tests/
vendor/bin/phpstan analyse src/ --level=5
vendor/bin/phpmd src/ text cleancode,codesize,controversial,design,naming,unusedcode
```

### Continuous Integration

[](#continuous-integration)

The project includes several GitHub Actions workflows:

- **Tests**: Runs on every push and pull request
- **Coverage**: Generates and uploads coverage reports
- **Security**: Weekly dependency security audits
- **Release**: Automated releases for tagged versions

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

[](#contributing)

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

### Development Guidelines

[](#development-guidelines)

1. Follow PSR-12 coding standards
2. Write comprehensive tests for new features
3. Update documentation for API changes
4. Ensure all CI checks pass before submitting PR

License
-------

[](#license)

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

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance50

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/030fe5fffddf0c329473564b64057c625a3a6e92b0841650d6b196fbc644e0a6?d=identicon)[bastian-schur](/maintainers/bastian-schur)

---

Top Contributors

[![bastian-schur](https://avatars.githubusercontent.com/u/2923151?v=4)](https://github.com/bastian-schur "bastian-schur (15 commits)")[![openhands-agent](https://avatars.githubusercontent.com/u/175740463?v=4)](https://github.com/openhands-agent "openhands-agent (10 commits)")

### Embed Badge

![Health badge](/badges/nodus-it-lexware-office-api/health.svg)

```
[![Health](https://phpackages.com/badges/nodus-it-lexware-office-api/health.svg)](https://phpackages.com/packages/nodus-it-lexware-office-api)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M186](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[microsoft/microsoft-graph

The Microsoft Graph SDK for PHP

65723.5M95](/packages/microsoft-microsoft-graph)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)

PHPackages © 2026

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