PHPackages                             worksome/company-info - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. worksome/company-info

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

worksome/company-info
=====================

Lookup company information

v1.5.0(4mo ago)33487.9k↑35.3%3[2 issues](https://github.com/worksome/company-info/issues)[2 PRs](https://github.com/worksome/company-info/pulls)MITPHPPHP ^8.4CI passing

Since Mar 25Pushed 2mo ago12 watchersCompare

[ Source](https://github.com/worksome/company-info)[ Packagist](https://packagist.org/packages/worksome/company-info)[ Docs](https://github.com/worksome/company-info)[ RSS](/packages/worksome-company-info/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (6)Dependencies (18)Versions (18)Used By (0)

Company Info
============

[](#company-info)

Lookup company information from public services.

[![Tests](https://github.com/worksome/company-info/actions/workflows/run-tests.yml/badge.svg)](https://github.com/worksome/company-info/actions/workflows/run-tests.yml)[![PHPStan](https://github.com/worksome/company-info/actions/workflows/phpstan.yml/badge.svg)](https://github.com/worksome/company-info/actions/workflows/phpstan.yml)

If your app needs information about a given company, then there are public service API's that can provide that information. It can be a lot of work implementing support for each different service, especially if you need it for several different countries.

The Company Info package provides a service that wraps the public services and gives you a simple way to perform the lookups.

Currently, the package supports the public service API's of the Danish VIRK and CVR API services and the GB Gazette service.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require worksome/company-info
```

You can publish the config file with:

```
php artisan vendor:publish --tag="company-info-config"
```

Configuration
-------------

[](#configuration)

The following environment variables are available to configure the package:

```
# Define the default country, used when a country is not given.
COMPANY_INFO_DEFAULT_COUNTRY=dk

# Define URL and credentials for the Danish CVR API service.
COMPANY_INFO_CVRAPI_BASE_URL=https://cvrapi.dk/api

# Define URL and credentials for the Danish VIRK service.
COMPANY_INFO_VIRK_BASE_URL=http://distribution.virk.dk
COMPANY_INFO_VIRK_USER_ID=xxx
COMPANY_INFO_VIRK_PASSWORD=xxx

# Define URL and credentials for the English Gazette service.
COMPANY_INFO_GAZETTE_BASE_URL=https://api.companieshouse.gov.uk
COMPANY_INFO_GAZETTE_KEY=xxx

# Define maximum number of results returned (works for VIRK and Gazette).
COMPANY_INFO_MAX_RESULTS=10

# Define the default provider for each country.
COMPANY_INFO_PROVIDER_DK=virk # Can also be cvrapi.
COMPANY_INFO_PROVIDER_GB=gazette
COMPANY_INFO_PROVIDER_NO=cvrapi
```

Usage
-----

[](#usage)

The package provides two general static methods, allowing you to perform company lookups from either name or number (in Denmark, the number is the CVR number).

The methods take a `country` parameter, which must be one of the supported countries, or left out or empty to use the configured default country.

The country code selects the appropriate underlying service for the lookup. Currently the package supports countries `dk` and `no` for the Danish CVR API service, `dk` for the Danish VIRK service and `gb` for the English Gazette service. If an invalid country is given, an `InvalidCountryException` is thrown.

Example lookups:

```
use Worksome\CompanyInfo\Facades\CompanyInfo;

$companies = CompanyInfo::lookupName('worksome', 'dk');
// - or -
$companies = CompanyInfo::lookupNumber('37990485', 'dk');
```

The lookup methods returns an array of companies matching the name or number, or `null` if the underlying service failed.

The array may be empty, if there are no companies matching the given name or number.

If there are matches (or just one), then each matching company can be found in the array.

### Company info data structure

[](#company-info-data-structure)

The company information is a simplified uniform representation of the data provided by the underlying service.

```
[
    'number'   => '37990485',
    'name'     => 'Worksome ApS',
    'address1' => 'Toldbodgade 35, 1.',
    'address2' => '',
    'zipcode'  => '1253',
    'city'     => 'København K',
    'country'  => 'DK',
    'phone'    => '71991931',
    'email'    => 'accounting@worksome.com',
]
```

The `number` field is the CVR number for the `dk` country and company number for the `gb` country.

Artisan
-------

[](#artisan)

The package adds a command for performing lookups at the commandline. This is probably most useful while configuring the services, to check if your access is working.

```
php artisan company-info:lookup --name=worksome --country=dk
php artisan company-info:lookup --number=37990485 --country=dk
```

The company information will be displayed in table format, unless option `--json` is given, then it is output in formatted JSON.

Documentation for services
--------------------------

[](#documentation-for-services)

### CVR API (DK)

[](#cvr-api-dk)

There is a [free Danish API service](https://cvrapi.dk/documentation) for CVR lookups, which does not require obtaining access from VIRK, but is rate-limited, so if you make a lot of requests, you might suddenly get a null result, which is due to a "QUOTA EXCEEDED" error from CVR API. You can pay to have a larger quota, or use the official VIRK service instead (see below).

### VIRK (DK)

[](#virk-dk)

VIRK is the official Danish service for CVR lookups. See some documentation [here](https://data.virk.dk/sites/default/files/soegeeksempler_v.6.x.pdf).

To obtain access and credentials to the Danish VIRK service, contact Erhvervsstyrelsen via this page: .

### Gazette (GB)

[](#gazette-gb)

This package uses the [company search](https://developer-specs.company-information.service.gov.uk/companies-house-public-data-api/reference/search/search-companies) part of the Gazette service.

To obtain access and credentials to the Gazette service, see .

Testing
-------

[](#testing)

To help you write tests using CompanyInfo, we provide a fake implementation via the `CompanyInfo::fake()` method.

```
