PHP code example of ivuorinen / business-data-fetcher

1. Go to this page and download the library: Download ivuorinen/business-data-fetcher 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/ */

    

ivuorinen / business-data-fetcher example snippets


use Ivuorinen\BusinessDataFetcher\BusinessDataFetcher;

$client = new BusinessDataFetcher();
$results = $client->getBusinessInformation('1639413-9');

foreach ($results as $company) {
    echo $company->name . "\n";
    echo $company->businessId . "\n";

    foreach ($company->names as $name) {
        echo $name->name . ' (' . $name->getLanguageString() . ")\n";
    }
}

use Ivuorinen\BusinessDataFetcher\v3\Client;

$client = new Client();

// Search by name
$result = $client->searchCompanies(name: 'Example');
echo "Found {$result->totalResults} companies\n";

foreach ($result->companies as $company) {
    echo $company->businessId->value . ' - ';
    echo $company->names[0]->name . "\n";
}

// Search by Business ID
$result = $client->searchCompanies(businessId: '1639413-9');

// Search with multiple filters
$result = $client->searchCompanies(
    location: 'Helsinki',
    companyForm: 'OY',
    mainBusinessLine: '62010',
);

// Get code list descriptions
$description = $client->getDescription('REK', 'en');

// Get postal codes
$postCodes = $client->getPostCodes('fi');

// Download all companies as ZIP
$stream = $client->getAllCompanies();
file_put_contents('companies.zip', $stream->getContents());