PHP code example of beziworld / laravel-krs

1. Go to this page and download the library: Download beziworld/laravel-krs 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/ */

    

beziworld / laravel-krs example snippets


use Beziworld\Krs\Facades\Krs;

$company = Krs::current('635012');   // leading zeros optional, "KRS 0000635012" works too

$company->krs;                 // "0000635012"
$company->register;            // Register::Entrepreneurs (P) or Register::Associations (S)
$company->name;                // "ALLEGRO SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ"
$company->legalForm;           // "SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ"
$company->nip;                 // "5252674798"
$company->regon;               // "365331553" (14-digit REGON padded with zeros is shortened)
$company->registeredAt;        // CarbonImmutable 2016-09-02
$company->address;             // Address: street, houseNumber, flatNumber, postalCode, city...
(string) $company->address;    // "UL. WIERZBIĘCICE 1B, 61-569 POZNAŃ"
$company->seat->voivodeship;   // "WIELKOPOLSKIE"
$company->shareCapital;        // Money: amount "40000000.00" (decimal string), currency "PLN"
$company->mainActivity;        // Pkd: code "63.12.Z", description
$company->pkdCodes();          // ["63.12.Z", "63.11.Z", "62.09.Z", "73.1", ...]
$company->eDeliveryAddress;    // "AE:PL-82834-96805-BTBTU-28"
$company->raw;                 // decoded API response, for fields not mapped above

$company->representation->body;     // "ZARZĄD"
$company->representationMethod();   // "DO SKŁADANIA OŚWIADCZEŃ W IMIENIU SPÓŁKI WYMAGANE JEST WSPÓŁDZIAŁANIE DWÓCH ..."

foreach ($company->representatives() as $member) {
    $member->name();       // "M***** P**** K*******"
    $member->role;         // "PREZES ZARZĄDU"
    $member->suspended;    // false
    $member->isMasked();   // true
}

$company->supervisoryBodies;        // list<Representation>, e.g. "RADA NADZORCZA"
$company->procurators[0]->role;     // "PROKURA ŁĄCZNA Z DRUGIM PROKURENTEM ALBO CZŁONKIEM ZARZĄDU"

foreach ($company->shareholders as $shareholder) {
    $shareholder->name();              // "ALLEGRO.EU SA"
    $shareholder->shares;              // "800.000 UDZIAŁÓW O ŁĄCZNEJ WARTOŚCI 40.000.000 ZŁ"
    $shareholder->shareCount();        // 800000
    $shareholder->ownsAllShares;       // true
    $shareholder->party->krs;          // KRS of a corporate shareholder, when published
    $shareholder->limitedPartner;      // limited partnerships: true for a komandytariusz
    $shareholder->limitedLiabilitySum; // "2000,00 PLN"
}

$company->isActive();             // not removed, not in liquidation, not bankrupt, activity not suspended
$company->isInLiquidation();      // $company->liquidation: opening, representationMethod, liquidators
$company->isBankrupt();           // $company->bankruptcy: court, caseNumber, declaredOn, trustees
$company->isInRestructuring();    // $company->restructuring: "PRZYMUSOWA RESTRUKTURYZACJA"
$company->isSuspended();          // $company->suspendedSince
$company->dissolution;            // "ROZWIĄZANIE"
$company->publicBenefit;          // public benefit organisation (OPP)

$extract = Krs::full('106150');

$extract->entries;                  // list<RegistryEntry>: number, description, date, caseNumber, court, finalOn
$extract->lastEntry()->description; // "WYKREŚLENIE Z KRAJOWEGO REJESTRU SĄDOWEGO"
$extract->isDeleted();              // true
$extract->company;                  // state in force, or the last state before removal
$extract->company->deletedAt;       // 2022-08-12

// Entities with entries made on a day: unique ten-digit numbers, fetched lazily
Krs::changedOn('2026-11-02')->take(10)->all();

// Hourly bulletin for 10:00-11:00 (Polish time)
Krs::changedOn(now(), fromHour: 10, toHour: 11);

// Several days, one request per day while iterating
Krs::changedBetween('2026-11-01', '2026-11-07')->each(fn (string $krs) => ...);

use Beziworld\Krs\Events\KrsEntryChanged;
use Beziworld\Krs\Facades\Krs;
use Beziworld\Krs\KrsWatcher;

// AppServiceProvider::boot(): watch the counterparties stored in the database
KrsWatcher::watchUsing(fn () => Contractor::whereNotNull('krs')->pluck('krs'));

Event::listen(function (KrsEntryChanged $event): void {
    $company = Krs::current($event->krs);   // fresh data, the cache was forgotten
    // update the contractor, notify the account manager...
});

// routes/console.php
Schedule::command('krs:watch')->dailyAt('06:00');               // yesterday's bulletin
Schedule::command('krs:watch --previous-hour')->hourlyAt(5);    // near real time

use Beziworld\Krs\Enums\Register;
use Beziworld\Krs\Rules\ExistsInKrs;

$request->validate([
    'krs' => ['tcy
    'foundation_krs' => ['
bash
php artisan krs:show 635012
php artisan krs:show 30897 --register=S
php artisan krs:show 106150 --full --entries=5
php artisan krs:watch 635012 19193 --date=2026-11-02
php artisan krs:watch --previous-hour