tor2r/laravel-brreg-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tor2r/laravel-brreg-api

最新稳定版本:v1.0.3

Composer 安装命令:

composer require tor2r/laravel-brreg-api

包简介

Fetch data from Brønnøysundregisteret.

README 文档

README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

A Laravel package for fetching basic data from Brønnøysundregisteret (the Norwegian Register of Business Enterprises). Supports both Enhetsregisteret and Frivillighetsregisteret.

Requirements

  • PHP 8.2 or higher
  • Laravel 11, 12, or 13

Installation

You can install the package via composer:

composer require tor2r/laravel-brreg-api

You can publish the config file with:

php artisan vendor:publish --tag="brreg-api-config"

This is the contents of the published config file:

return [
    'base_url' => env('BRREG_API_BASE_URL', 'https://data.brreg.no'),
    'results_per_page' => env('BRREG_API_RESULTS_PER_PAGE', 100),
];

Usage

Enhetsregisteret (Business Registry)

use Tor2r\BrregApi\Facades\BrregApi;

// Fetch a single entity by organisation number
$entity = BrregApi::getByOrgnr('987654321');

// Search by name
$results = BrregApi::searchByName('Sesam');

// Limit the number of results
$results = BrregApi::searchByName('Sesam', 10);

Frivillighetsregisteret (Voluntary Organisations Registry)

// Fetch a single voluntary organisation
$org = BrregApi::voluntary()->getByOrgnr('987654321');

// Search voluntary organisations by name
$results = BrregApi::voluntary()->searchByName('Frivillig');

Response Format

Single entity (getByOrgnr) returns a flat array with the entity data:

$entity = BrregApi::getByOrgnr('925183873');

// [
//     'organisasjonsnummer' => '925183873',
//     'navn' => 'FAGFOKUS AS',
//     'organisasjonsform' => [...],
//     'forretningsadresse' => [...],
//     'antallAnsatte' => 7,
//     ...
// ]

Search methods (searchByName) return a structured response with data and meta:

$results = BrregApi::searchByName('Fagfokus');

// [
//     'data' => [
//         [
//             'organisasjonsnummer' => '925183873',
//             'navn' => 'FAGFOKUS AS',
//             'antallAnsatte' => 7,
//             ...
//         ],
//     ],
//     'meta' => [
//         'per_page' => 100,
//         'total' => 1,
//         'total_pages' => 1,
//         'current_page' => 0,
//     ],
// ]

Internal API fields (_links, respons_klasse) are automatically stripped from responses.

Error Handling

The package throws Tor2r\BrregApi\Exceptions\BrregApiException when something goes wrong:

use Tor2r\BrregApi\Exceptions\BrregApiException;

try {
    $entity = BrregApi::getByOrgnr('000000000');
} catch (BrregApiException $e) {
    // "No entity found with organisation number: 000000000"
    echo $e->getMessage();
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 140
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固