PHPackages                             oryx/adr - 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. oryx/adr

ActiveLibrary

oryx/adr
========

Action Domain Responder (ADR) library for PHP, compatible with oryx/mvc and PWA middleware

2.0.0(1mo ago)00BSD-3-ClausePHPPHP ^8.1

Since Mar 28Pushed 1mo agoCompare

[ Source](https://github.com/pbrilius/adr)[ Packagist](https://packagist.org/packages/oryx/adr)[ RSS](/packages/oryx-adr/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (4)Used By (0)

oryx/adr
========

[](#oryxadr)

Action Domain Responder (ADR) library for PHP, compatible with oryx/mvc and PWA middleware.

Overview
--------

[](#overview)

This library implements the Action Domain Responder (ADR) pattern, a refinement of the MVC pattern that separates concerns into:

- **Action**: Receives input and delegates to Domain
- **Domain**: Contains business logic
- **Responder**: Prepares and returns HTTP responses

The library includes:

- ADR pattern interfaces and abstract base classes
- ManifestJsonMiddleware for PWA compatibility
- PSR-15 compliant middleware integration
- PSR-4 autoloading
- JSON:API and Problem Details (RFC 7807) responders

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

[](#installation)

```
composer require oryx/adr
```

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

[](#requirements)

- PHP 8.1+
- PSR interfaces (http-message, http-server-middleware)
- Laminas Diactoros (for JSON responses)
- oryx/mvc (framework integration)

Usage
-----

[](#usage)

### Basic ADR Implementation

[](#basic-adr-implementation)

```
use Oryx\Adr\Action\ActionInterface;
use Oryx\Adr\Domain\DomainInterface;
use Oryx\Adr\Responder\ResponderFactory;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface as PsrResponseInterface;
use Laminas\Diactoros\ServerRequest;
use Laminas\Diactoros\Response;

// Define your domain
class UserDomain implements DomainInterface {
    public function getUserProfile(int $userId): array {
        // Business logic here
        return [
            'id' => $userId,
            'name' => 'John Doe',
            'email' => 'john@example.com'
        ];
    }
}

// Define your responder
class JsonApiResponder implements ResponderInterface {
    private $data;

    public function __construct(array $data) {
        $this->data = $data;
    }

    public function respond(): ResponseInterface {
        // Simplified JSON:API responder for example
        return new \Laminas\Diactoros\JsonResponse($this->data);
    }
}

// Define your action
class GetUserProfileAction implements ActionInterface {
    private UserDomain $domain;
    private ResponderFactory $responderFactory;

    public function __construct(UserDomain $domain, ResponderFactory $responderFactory) {
        $this->domain = $domain;
        $this->responderFactory = $responderFactory;
    }

    public function execute(DomainInterface $domain): string {
        // Extract user ID from request (in real implementation)
        $userId = 123;

        // Delegate to domain
        $userData = $domain->getUserProfile($userId);

        // Return responder class name
        return JsonApiResponder::class;
    }

    public function __invoke(ServerRequestInterface $request, PsrResponseInterface $response, callable $next = null): PsrResponseInterface
    {
        // Execute the action to get the responder class name
        $responderClass = $this->execute($this->domain);

        // Create the responder instance using the factory
        $responderInstance = $this->responderFactory->create($responderClass);

        // Generate and return the response
        return $responderInstance->respond();
    }
}

// Usage in oryx/mvc
$app = new \Oryx\Mvc\Application();
$container = $app->getContainer();

// Register your domain and responder factory with the container
// Example:
// $container->set(UserDomain::class, new UserDomain());
// $container->set(\Oryx\Adr\Responder\ResponderFactory::class,
//     new \Oryx\Adr\Responder\DefaultResponderFactory($container));

// Then create your action and process the request.
```

### Using Built-in Responders

[](#using-built-in-responders)

```
use Oryx\Adr\Responder\JsonApiResponder;
use Oryx\Adr\Responder\ProblemDetailsResponder;

// JSON:API responder for successful responses
$jsonApiResponder = new JsonApiResponder([
    'data' => [
        'type' => 'users',
        'id' => '1',
        'attributes' => [
            'name' => 'John Doe',
            'email' => 'john@example.com'
        ]
    ]
]);

// Problem Details responder for error responses
$problemDetailsResponder = new ProblemDetailsResponder(
    'https://example.com/probs/out-of-credit',
    'You do not have enough credit.',
    403,
    'Your account has only 5 USD left.',
    'https://example.com/account/12345/msgs/abc'
);
```

### Using with oryx/mvc Middleware

[](#using-with-oryxmvc-middleware)

The ManifestJsonMiddleware is PSR-15 compliant and can be used directly with oryx/mvc:

```
use Oryx\Adr\Middleware\ManifestJsonMiddleware;
use Oryx\Mvc\Application;

// Create application
$app = new Application();

// Add PWA manifest middleware
$app->addMiddleware(new ManifestJsonMiddleware());

// Add other middleware and routes...
$app->run();
```

### ManifestJsonMiddleware Features

[](#manifestjsonmiddleware-features)

The ManifestJsonMiddleware automatically handles requests for:

- `/manifest.json`
- `/manifest.webmanifest`

It returns a standard PWA manifest with:

- App name and short name
- Description
- Start URL
- Display mode
- Theme and background colors
- Icon array for various sizes

The middleware delegates all other requests to the next middleware in the queue.

PWA Compatibility
-----------------

[](#pwa-compatibility)

This library provides PWA compatibility through the ManifestJsonMiddleware which serves the web app manifest required for:

- Installable PWAs
- Offline capabilities (when combined with service workers)
- Mobile app-like experience

For full PWA functionality, combine this middleware with:

- Service worker middleware (for offline caching)
- Secure HTTPS connection
- Proper icon assets

Testing
-------

[](#testing)

Run the test suite:

```
vendor/bin/phpunit
```

License
-------

[](#license)

This library is licensed under the BSD 3-Clause License - see the [LICENSE](LICENSE) file for details.

Contributing
------------

[](#contributing)

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -am 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Create a new Pull Request

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance90

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

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 ~0 days

Total

2

Last Release

46d ago

Major Versions

v1.0.0 → 2.0.02026-03-28

### Community

Maintainers

![](https://www.gravatar.com/avatar/cee8274bb15a13bb51a04700b2875beeb635bc2d2889defa2e1493627c85a02c?d=identicon)[committee-lan-hackeris](/maintainers/committee-lan-hackeris)

---

Top Contributors

[![pbrilius](https://avatars.githubusercontent.com/u/8288767?v=4)](https://github.com/pbrilius "pbrilius (11 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/oryx-adr/health.svg)

```
[![Health](https://phpackages.com/badges/oryx-adr/health.svg)](https://phpackages.com/packages/oryx-adr)
```

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[cakephp/authentication

Authentication plugin for CakePHP

1153.6M67](/packages/cakephp-authentication)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[rareloop/lumberjack-core

A powerful MVC framework for the modern WordPress developer. Write better, more expressive and easier to maintain code

42155.0k19](/packages/rareloop-lumberjack-core)[neos/flow

Flow Application Framework

862.0M451](/packages/neos-flow)[neos/flow-development-collection

Flow packages in a joined repository for pull requests.

144179.3k3](/packages/neos-flow-development-collection)

PHPackages © 2026

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