1. Go to this page and download the library: Download dij-digital/kvk-laravel 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/ */
use DIJ\Kvk\Facades\KVK;
// List all subscriptions
$subscriptions = KVK::subscriptions()->get();
echo $subscriptions->customerId; // 'customer-123'
foreach ($subscriptions->subscriptions as $sub) {
echo $sub->id; // 'subscription-456'
echo $sub->startDate; // '2024-01-01T00:00:00Z'
echo $sub->active; // true
}
// Get signals (change notifications) for a subscription
$signals = KVK::subscriptions()
->subscription('subscription-456')
->from('2024-01-01T00:00:00Z')
->to('2024-12-31T23:59:59Z')
->page(1)
->resultsPerPage(50)
->signals();
foreach ($signals->signals as $signal) {
echo $signal->kvkNumber; // '69792917'
echo $signal->signalType; // 'SignaalGewijzigdeInschrijving'
echo $signal->timestamp; // '2024-05-14T15:25:13.773Z'
}
// Get a specific signal's full details
$signal = KVK::subscriptions()
->subscription('subscription-456')
->signal('signal-001');
echo $signal->messageId; // '3e96fad5-...'
echo $signal->signalType; // 'SignaalGewijzigdeInschrijving'
echo $signal->registrationTimestamp; // '2024-05-14T15:25:13.773Z'
echo $signal->relatesTo['kvkNummer']; // '69792917'
use DIJ\Kvk\Exceptions\KvkAuthenticationException;
use DIJ\Kvk\Exceptions\KvkException;
try {
$result = KVK::search()->kvkNumber('69599068')->get();
} catch (KvkAuthenticationException $e) {
// Invalid API key — check KVK_API_KEY in .env
$e->statusCode; // 401
$e->responseBody; // raw response body
} catch (KvkException $e) {
// Any other API error
$e->statusCode;
$e->responseBody;
}
use DIJ\Kvk\Facades\KVK;
KVK::fake();
$result = KVK::search()->kvkNumber('69599068')->get();
// Returns a SearchResult with 0 items — no HTTP calls made
use DIJ\Kvk\Data\Responses\BaseProfileResponse;
use DIJ\Kvk\Data\Responses\SearchResponse;
use DIJ\Kvk\Data\ValueObjects\SbiActivity;
use DIJ\Kvk\Facades\KVK;
// Search faking — use withSearchResponses() on the returned FakeKVK
KVK::fake()->withSearchResponses(
SearchResponse::fake(kvkNumber: '69599068', name: 'Acme BV'),
SearchResponse::fake(kvkNumber: '12345678', name: 'Other BV'),
);
$result = KVK::search()->get();
// $result->total === 2
// $result->items->first()->kvkNumber === '69599068'
// Customize nested data — e.g., test a specific SBI code
KVK::fake(
baseProfile: BaseProfileResponse::fake(
sbiActivities: [SbiActivity::fake(sbiCode: '86101')],
),
);
$profile = KVK::baseProfile('69599068')->get();
echo $profile->sbiActivities[0]->sbiCode; // '86101'