Symfony bundle to integrate the lexware office (lexoffice) API. https://var-lab.com/?_src=github&_repo=lexoffice-bundle
Find a file
Anton Dachauer 5e109b411d
All checks were successful
security-check / security_checks (pull_request) Successful in 31s
Tests / tests (lint:composer, 8.3) (pull_request) Successful in 56s
Tests / tests (lint:composer, 8.4) (pull_request) Successful in 3m31s
Tests / tests (lint:composer, 8.2) (pull_request) Successful in 4m19s
Tests / tests (lint:php, 8.3) (pull_request) Successful in 32s
Tests / tests (phpstan, 8.2) (pull_request) Successful in 39s
Tests / tests (lint:php, 8.4) (pull_request) Successful in 56s
Tests / tests (lint:php, 8.2) (pull_request) Successful in 4m25s
Tests / tests (phpstan, 8.3) (pull_request) Successful in 34s
Tests / tests (tests:integration, 8.3) (pull_request) Successful in 30s
Tests / tests (phpstan, 8.4) (pull_request) Successful in 1m2s
Tests / tests (tests:integration, 8.2) (pull_request) Successful in 1m17s
Tests / tests (tests:integration, 8.4) (pull_request) Successful in 30s
Tests / tests (tests:unit:ci, 8.4) (pull_request) Successful in 37s
Tests / tests (tests:unit:ci, 8.2) (pull_request) Successful in 1m23s
Tests / tests (tests:unit:ci, 8.3) (pull_request) Successful in 1m1s
Tests / tests (lint:composer, 8.4) (push) Successful in 53s
Tests / tests (lint:composer, 8.3) (push) Successful in 3m32s
Tests / tests (lint:php, 8.3) (push) Successful in 32s
Tests / tests (lint:composer, 8.2) (push) Successful in 4m21s
Tests / tests (lint:php, 8.4) (push) Successful in 30s
Tests / tests (phpstan, 8.3) (push) Successful in 34s
Tests / tests (lint:php, 8.2) (push) Successful in 4m18s
Tests / tests (phpstan, 8.4) (push) Successful in 33s
Tests / tests (phpstan, 8.2) (push) Successful in 1m26s
Tests / tests (tests:integration, 8.3) (push) Successful in 30s
Tests / tests (tests:integration, 8.2) (push) Successful in 1m15s
Tests / tests (tests:integration, 8.4) (push) Successful in 58s
Tests / tests (tests:unit:ci, 8.2) (push) Successful in 42s
Tests / tests (tests:unit:ci, 8.3) (push) Successful in 59s
Tests / tests (tests:unit:ci, 8.4) (push) Successful in 1m3s
fix composer.json
2025-10-27 13:01:57 +01:00
.forgejo/workflows enable workflows 2025-10-27 12:41:31 +01:00
docker v0.1 [moved from gitlab] 2024-05-24 17:36:50 +02:00
src Fix +1 on version field on updating contact 2024-06-08 17:52:29 +02:00
tests Update dependencies 2025-03-03 14:01:16 +01:00
.gitignore v0.1 [moved from gitlab] 2024-05-24 17:36:50 +02:00
composer.json fix composer.json 2025-10-27 13:01:57 +01:00
composer.lock fix composer.json 2025-10-27 13:01:57 +01:00
CONTRIBUTING.md Fix CONTRIBUTING.md 2024-05-25 12:08:57 +02:00
docker-compose.yml Symfon 7.x compatibility 2024-10-05 12:32:44 +02:00
Dockerfile Add support for PHP 8.4 2025-04-07 13:25:07 +02:00
LICENSE v0.1 [moved from gitlab] 2024-05-24 17:36:50 +02:00
Makefile fix makefile 2025-04-07 13:14:36 +02:00
phpstan.neon v0.1 [moved from gitlab] 2024-05-24 17:36:50 +02:00
phpunit.xml.dist v0.1 [moved from gitlab] 2024-05-24 17:36:50 +02:00
README.md Configure workflows 2024-05-24 22:00:47 +02:00

lexoffice-Bundle for Symfony

Introduction

This bundle integrates the lexoffice public API into Symfony, utilizing Symfony's serializer to convert API responses into objects. Compatible with Symfony 6.4.

Installation

  1. Download the Bundle

Add the bundle to your composer.json:

composer require var-lab/lexoffice-bundle

2. Register the Bundle

(should be done automatically by composer)


    return [
        // ...
        VarLabIT\LexofficeBundle\VarLabITLexofficeBundle::class => ['all' => true],
    ];

3. Add configuration

Create the config file config/packages/var_lab_it_lexoffice.yaml with following content:

var_lab_it_lexoffice:
  api_key: '%env(LEXOFFICE_API_KEY)%'

add the api key to your .env:

# ...
LEXOFFICE_API_KEY=<your-api-key>

Usage

The following API functions are currently covered:

  • Contacts
    • fetch contact
    • create contact
    • update contact
  • Invoices
    • create invoice
    • update invoice
    • fetch invoice
    • download invoice pdf

The lexoffice bundle is currently undergoing further development. Your own pull requests are welcome.

Contacts

Create a new contact:

<?php

use VarLabIT\LexofficeBundle\Entity\Address;
use VarLabIT\LexofficeBundle\Entity\Company as LexofficeCompany;
use VarLabIT\LexofficeBundle\Entity\Contact;
use VarLabIT\LexofficeBundle\Entity\ContactRole;
use VarLabIT\LexofficeBundle\Entity\Enum\AddressType;
use VarLabIT\LexofficeBundle\Entity\Enum\RoleType;
use VarLabIT\LexofficeBundle\Entity\Person;
use VarLabIT\LexofficeBundle\LexofficeClient;

class CityPageController extends AbstractController {
    
    public function __construct(
        private readonly CompanyRepository        $companyRepository,
        private readonly LexofficeClient          $lexofficeClient,
    )
    {
    }

    private function getContactObject(Company $company): Contact
    {
        $contact = new Contact();
        $contact
            ->setVersion(0)
            ->addRole(RoleType::CUSTOMER, new ContactRole())
            ->setCompany(
                (new LexofficeCompany())
                    ->setName($company->getName())
                    ->addContactPerson(
                        (new Person())
                            ->setFirstName($company->getGivenName())
                            ->setLastName($company->getFamilyName())
                            ->setEmailAddress($company->getInvoiceEmail())
                            ->setPrimary(true)
                            ->setPhoneNumber($company->getContactPhone())
                    ),
            )
            ->addAddress(
                AddressType::BILLING,
                (new Address())
                    ->setSupplement('Rechnungsadresse')
                    ->setStreet($company->getAddress())
                    ->setZip($company->getZipcode())
                    ->setCity($company->getCity())
                    ->setCountryCode($company->getCountry())
            );
            
        return $contact;
    }

    public function createContact(int $companyId): Response {
        $company = $this->companyRepository->find($companyId);
        $contact = $this->createContact($company);
        
        $contact = $this->lexofficeClient->createContact($contact);
        
        $company
            ->setVersion($contact->getVersion())
            ->setLexofficeId($contact->getId());
    }
}

Update a contact:


    public function createContact(int $companyId): Response {
        $company = $this->companyRepository->find($companyId);
        $contact = $this->createContact($company);
        
        $contact = $this->lexofficeClient->updateContact($contact);
        
        $company
            ->setVersion($contact->getVersion())
            ->setLexofficeId($contact->getId());
    }

Maintainer

This bundle is maintained and created by var-lab IT GmbH and contributors.