1. Go to this page and download the library: Download gosuccess/easybill-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gosuccess / easybill-api example snippets
use GoSuccess\Easybill\Client;
use GoSuccess\Easybill\ClientConfig;
$client = new Client(new ClientConfig(
token: 'your-api-key',
// easybill allows 10 or 60 requests/minute depending on your plan.
// Set this to match YOUR limit so the client never hits a 429:
requestsPerMinute: 60,
));
// Fetch a single customer
$customer = $client->customers->get(12345);
echo $customer->companyName;
// Create a customer
use GoSuccess\Easybill\Model\Customer;
use GoSuccess\Easybill\Enum\Salutation;
$created = $client->customers->create(new Customer(
companyName: 'ACME GmbH',
salutation: Salutation::Company,
emails: ['[email protected]'],
));
use GoSuccess\Easybill\Model\Customer;
// Renames the customer. Every other field keeps its current value.
$client->customers->update(12345, new Customer(companyName: 'ACME SE'));
// Clears the note: `null` is sent as an explicit JSON null.
$client->customers->update(12345, new Customer(note: null));
// Same for lists — `[]` empties them.
$client->customers->update(12345, new Customer(emails: []));
use GoSuccess\Easybill\Model\Undefined;
$client->customers->update(12345, new Customer(
note: $clearNote ? null : Undefined::Value,
));
use GoSuccess\Easybill\Filter\CustomerFilter;
use GoSuccess\Easybill\Filter\DocumentFilter;
use GoSuccess\Easybill\Enum\DocumentType;
// One page
$page = $client->customers->list(page: 1, limit: 100, filter: new CustomerFilter(country: 'DE'));
echo $page->total, ' customers in total';
// All customers, transparently across pages
foreach ($client->customers->all(new CustomerFilter(country: 'DE')) as $customer) {
echo $customer->companyName, PHP_EOL;
}
// Enum-typed filters, e.g. only draft invoices
foreach ($client->documents->all(new DocumentFilter(type: DocumentType::Invoice, isDraft: true)) as $document) {
// ...
}
use GoSuccess\Easybill\Client;
use GoSuccess\Easybill\ClientConfig;
$client = new Client(
config: new ClientConfig(token: 'your-api-key'),
rateLimiter: new MyRedisRateLimiter(/* ... */),
);
use GoSuccess\Easybill\Exception\NotFoundException;
use GoSuccess\Easybill\Exception\RateLimitException;
use GoSuccess\Easybill\Exception\ValidationException;
try {
$client->customers->get(999999);
} catch (NotFoundException $e) {
// 404
} catch (ValidationException $e) {
// 422 — inspect $e->responseBody
} catch (RateLimitException $e) {
// 429 — $e->retryAfter holds the seconds to wait, if provided
}
use GoSuccess\Easybill\Client;
use GoSuccess\Easybill\ClientConfig;
use GoSuccess\Easybill\Http\HttpClient;
use GoSuccess\Easybill\Http\Request;
use GoSuccess\Easybill\Http\Response;
final class GuzzleTransport implements HttpClient
{
public function send(Request $request): Response { /* ... */ }
}
$client = new Client(
config: new ClientConfig(token: 'your-api-key'),
httpClient: new GuzzleTransport(),
);
bash
php tools/generate-models.php # enums, DTOs and typed filters (from the snapshot)
php tools/generate-resources.php # the plain CRUD/partial resource classes
php tools/generate-docs.php # the per-method reference pages under docs/
composer cs-fix # apply code style
composer check # php-cs-fixer + phpstan (level max) + phpunit