Search by

adachsoft / principal-contact

Arkadiusz Adach

Contact data of principals for any PHP application: contact service with access policy, e-mail and phone validators and an e-mail address resolver for adachsoft/notification-channel-email.

Package info

gitlab.com/a.adach/principal-contact

Issues

pkg:composer/adachsoft/principal-contact

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.0 2026-11-25 01:41 UTC

This package is auto-updated.

Last update: 2026-11-25 00:41:33 UTC


README

adachsoft/principal-contact manages contact details for application principals such as users, accounts, or groups. It provides an access-controlled contact service, e-mail and phone validation, and an e-mail address resolver for notification integrations. Storage is supplied through a repository contract, so applications can choose an adapter.

Requirements and installation

  • PHP 8.3 or newer
  • Composer
composer require adachsoft/principal-contact

Usage

Create a repository and service, then use principal references from adachsoft/reference-contracts:

use AdachSoft\PrincipalContact\Service\ContactServiceFactory;
use AdachSoft\PrincipalContactContracts\InMemory\InMemoryPrincipalContactsRepository;
use AdachSoft\ReferenceContracts\PrincipalReference;

$repository = new InMemoryPrincipalContactsRepository();
$service = ContactServiceFactory::create($repository);
$principal = new PrincipalReference('account', 'account-42');

$contacts = $service->contactsOf($principal, $principal);

The factory defaults to self-only access, built-in e-mail and phone validators, and a system clock. Applications can provide a custom access policy, validator registry, change listener, or PSR-20 clock. replaceContacts() validates and normalizes values, supports optimistic version checks, and notifies an optional listener when contacts change.

See Basic usage for a complete example covering contact updates, access denial, normalization, versioning, and e-mail resolution.

Storage and notifications

The in-memory repository from adachsoft/principal-contact-contracts is suitable for tests and short-lived processes. For persistent JSON-file storage, install adachsoft/principal-contact-json-file and pass its repository implementation to the factory.

ContactEmailAddressResolver adapts the repository to adachsoft/notification-channel-email. The notification channel and a transport implementation can be integrated separately.