PHPackages                             nictorgersen/kreg-php-client - 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. [API Development](/categories/api)
4. /
5. nictorgersen/kreg-php-client

ActiveLibrary[API Development](/categories/api)

nictorgersen/kreg-php-client
============================

PHP client for KREG API using Laravel HTTP client

1.1.2(3mo ago)2121↓66.7%MITPHPPHP ^8.2

Since Nov 12Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/NicTorgersen/kreg-php-client)[ Packagist](https://packagist.org/packages/nictorgersen/kreg-php-client)[ RSS](/packages/nictorgersen-kreg-php-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (8)Versions (5)Used By (0)

KREG PHP API
============

[](#kreg-php-api)

A modern PHP wrapper for the KREG API (Norwegian competence registry system) built with Laravel's HTTP client.

Features
--------

[](#features)

- 🚀 **Laravel Integration** - Service provider, facade, and auto-discovery
- 🔒 **Session Management** - Automatic session handling with SHA-256 authentication
- 📦 **Resource-Based API** - Clean, intuitive interface for all KREG resources
- ✅ **Fully Tested** - Comprehensive test suite with Pest
- 🎯 **Type-Safe** - PHP 8.2+ with readonly properties and strict types
- 🔄 **Laravel 10, 11, 12** - Full support for all modern Laravel versions

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

[](#installation)

Install via Composer:

```
composer require nictorgersen/kreg-php-client
```

Quick Start
-----------

[](#quick-start)

### Laravel

[](#laravel)

The package auto-registers in Laravel. Just publish the config and start using the facade:

```
php artisan vendor:publish --tag="kreg-config"
```

Configure your credentials in `.env`:

```
KREG_SYSTEM_TOKEN=your-system-token
KREG_COMPANY_TOKEN=your-company-token
```

Use the facade:

```
use NicTorgersen\KregApiSdk\Facades\Kreg;

// List persons
$persons = Kreg::person()->list();

// Create a person
$person = Kreg::person()->create(
    firstName: 'John',
    lastName: 'Doe',
    birthDate: '1990-01-01'
);

// Manage competences
$competence = Kreg::competence()->create(
    personId: $person->id,
    competenceId: 123,
    validFrom: '2024-01-01',
    validTo: '2025-01-01'
);
```

### Plain PHP

[](#plain-php)

```
use NicTorgersen\KregApiSdk\KregClient;
use NicTorgersen\KregApiSdk\KregConfig;

$config = KregConfig::make(
    systemToken: 'your-system-token',
    companyToken: 'your-company-token'
);

$client = KregClient::make($config);

// Use the client
$persons = $client->person()->list();
```

Available Resources
-------------------

[](#available-resources)

The package provides access to all KREG API resources:

- **Person** - Manage persons (create, read, update, delete, find)
- **Competence** - Manage competences for persons
- **Document** - Manage documents for persons
- **Catalog** - Access catalog data (competence types, etc.)
- **Companies** - Manage and list companies
- **ExternalCourse** - Manage LMS courses linked to KREG's competency catalog

Examples
--------

[](#examples)

Comprehensive examples are available in the [`examples/`](./examples) directory:

- **[Laravel Example](./examples/example-with-laravel)** - Complete Laravel integration with facade usage, dependency injection, and testing
- **[Plain PHP Example](./examples/plain-php)** - Framework-agnostic usage with runnable examples

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Laravel 10.x, 11.x, or 12.x (for Laravel integration)

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Format code with Laravel Pint:

```
composer format
```

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

[](#configuration)

The package uses the following configuration options:

OptionDescriptionDefault`system_token`Your KREG system tokenRequired`company_token`Your KREG company tokenRequired`base_url`KREG API base URL`https://kreg.sr.no/kreg/v1/``session_duration`Session validity in seconds`86400` (24 hours)`timeout`HTTP request timeout in seconds`30`Error Handling
--------------

[](#error-handling)

The package provides specific exception types:

```
use NicTorgersen\KregApiSdk\Exceptions\Kregception;
use NicTorgersen\KregApiSdk\Exceptions\KregAuthenticationException;
use NicTorgersen\KregApiSdk\Exceptions\KregNotFoundException;
use NicTorgersen\KregApiSdk\Exceptions\KregValidationException;

try {
    $person = Kreg::person()->get($id);
} catch (KregNotFoundException $e) {
    // Person not found
} catch (KregAuthenticationException $e) {
    // Authentication failed
} catch (KregValidationException $e) {
    // Validation error
} catch (Kregception $e) {
    // General API error
}
```

License
-------

[](#license)

MIT

Credits
-------

[](#credits)

- [Nichlas Torgersen](https://github.com/nictorgersen)

Support
-------

[](#support)

For issues or questions, please use the [GitHub issue tracker](https://github.com/nictorgersen/kreg-php-client/issues).

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance78

Regular maintenance activity

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~22 days

Total

4

Last Release

118d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d2935c4c35a1c5dc96c01742aa712fd2a447ec3d8fbfd040748ee4faf798d296?d=identicon)[NicTorgersen](/maintainers/NicTorgersen)

---

Top Contributors

[![NicTorgersen](https://avatars.githubusercontent.com/u/1327106?v=4)](https://github.com/NicTorgersen "NicTorgersen (10 commits)")

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/nictorgersen-kreg-php-client/health.svg)

```
[![Health](https://phpackages.com/badges/nictorgersen-kreg-php-client/health.svg)](https://phpackages.com/packages/nictorgersen-kreg-php-client)
```

###  Alternatives

[spatie/laravel-query-builder

Easily build Eloquent queries from API requests

4.4k26.9M220](/packages/spatie-laravel-query-builder)[spatie/laravel-route-discovery

Auto register routes using PHP attributes

23645.0k2](/packages/spatie-laravel-route-discovery)[simplestats-io/laravel-client

Client for SimpleStats!

4515.5k](/packages/simplestats-io-laravel-client)[esign/laravel-conversions-api

A laravel wrapper package around the Facebook Conversions API

69145.4k](/packages/esign-laravel-conversions-api)[ryangjchandler/bearer

Minimalistic token-based authentication for Laravel API endpoints.

8129.8k](/packages/ryangjchandler-bearer)[stechstudio/laravel-hubspot

A Laravel SDK for the HubSpot CRM Api

2971.0k](/packages/stechstudio-laravel-hubspot)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
