philharmonie / lexware-office-laravel
Lexware Office API integration for Laravel
Fund package maintenance!
philharmonie
www.paypal.com/paypalme/pharmonie
Requires
- php: ^8.2
- guzzlehttp/guzzle: ^7.0
- illuminate/http: ^10.0|^11.0
- illuminate/support: ^10.0|^11.0
Requires (Dev)
- laravel/pint: ^1.19
- mockery/mockery: ^1.6
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.28.1
- phpstan/phpstan: ^1.10.50
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-strict-rules: ^1.5
- rector/rector: ^1.0
- symfony/var-dumper: ^6.4.0|^7.0.0
README
A Laravel package for seamless integration with the Lexware Office API. This package provides an elegant way to interact with Lexware Office services, including contacts and invoices management.
Requirements
- PHP ^8.2
- Laravel ^10.0|^11.0
- Guzzle ^7.0
Installation
You can install the package via composer:
composer require philharmonie/lexware-office-laravel
Service Provider
The service provider is automatically registered using Laravel's auto-discovery feature. If you need to register it manually, add the following line to the providers array in config/app.php
:
PhilHarmonie\LexOffice\ServiceProvider::class,
Configuration
Publish the configuration file:
php artisan vendor:publish --tag="lexoffice-config"
Add your Lexware Office API key to your .env
file:
LEXOFFICE_API_KEY=your-api-key
Usage
Contacts
// Find a contact by ID $contact = app(ContactService::class)->find('contact-id'); // List contacts with optional filters $contacts = app(ContactService::class)->list([ 'email' => 'example@domain.com' ]);
Invoices
// Create an invoice $invoice = app(InvoiceService::class)->create([ // Invoice data ], $finalize = false); // Find an invoice by ID $invoice = app(InvoiceServiceInterface::class)->find('invoice-id');
Using the Facades
use PhilHarmonie\LexOffice\Facades\Contact;use PhilHarmonie\LexOffice\Facades\Invoice; // Find a contact $contact = Contact::find('contact-id'); // List contacts $contacts = Contact::list(['email' => 'example@domain.com']); // Create an invoice $invoice = Invoice::create($data, $finalize = false); // Find an invoice $invoice = Invoice::find('invoice-id');
Direct Client Usage
If you need more control, you can use the client directly:
use PhilHarmonie\LexOffice\Contracts\ClientInterface; $client = app(ClientInterface::class); // GET request $response = $client->get('/contacts', ['email' => 'example@domain.com']); // POST request $response = $client->post('/invoices', ['data' => 'value']);
Using Builders
The package provides fluent builders for creating invoices and related structures:
use PhilHarmonie\LexOffice\Builders\InvoiceBuilder; use PhilHarmonie\LexOffice\Builders\AddressBuilder; use PhilHarmonie\LexOffice\Builders\LineItemBuilder; $invoice = InvoiceBuilder::make() ->timezone('Europe/Berlin') ->voucherDate(now()) ->address( AddressBuilder::make() ->name('Company Name') ->supplement('c/o John Doe') ->street('Street 123') ->city('City') ->zip('12345') ->countryCode('DE') ) ->addLineItem( LineItemBuilder::custom() ->name('Product') ->description('Detailed description of the product') ->quantity(1) ->unitName('piece') ->unitPrice('EUR', 99.99, 19.0) ) ->addLineItem( LineItemBuilder::text() ->name('Note') ->description('Additional context for the invoice') ) ->taxConditions('net') ->paymentConditions( label: '10 days - 3%', duration: 30, discountPercentage: 3.0, discountRange: 10 ) ->shippingConditions( date: now()->addDays(5), type: 'delivery' ) ->title('Invoice') ->introduction('Introduction text for the invoice') ->remark('Thank you for your business!') ->toArray();
Testing
composer test
This will run:
- Code style checks (Pint)
- Static analysis (PHPStan)
- Unit tests (Pest)
- Refactoring checks (Rector)
Individual test commands:
composer test:lint # Run Laravel Pint composer test:types # Run PHPStan composer test:unit # Run Pest tests composer test:refacto # Run Rector
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email phil@harmonie.media instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.