phprise / http-connector
Atomic repository for connector HTTP based on The OTAKU Manifesto.
Installs: 1
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/phprise/http-connector
Requires
- php: ^8.4
- php-http/httplug: ^2.4
- php-http/promise: ^1.3
- phprise/http-contract: ^1.0
- psr/event-dispatcher: ^1.0
- psr/http-client: ^1.0
- psr/http-message: ^2.0
Requires (Dev)
- phpunit/phpunit: ^12.5
- vimeo/psalm: ^6.14
README
The Atomic Repository is the smallest possible unit of granularity. It enforces a strict architectural boundary through the following rules:
- No Subdirectories: Only one level of directory inside src/.
- Maximum 10 Files: Only 10 files per package.
- Strict Typing: Mandatory
declare(strict_types=1)and full type hinting for all properties and methods. - Object Calisthenics: Maximum of 50 lines per class and 2 instance variables to ensure extreme cohesion.
- Value Objects: All primitives must be wrapped. Raw strings or integers are not permitted in domain logic.
- First Class Collections: Arrays are forbidden for data transport; use dedicated Collection objects.
- Tell, Don't Ask: Getters and setters are prohibited. Objects must expose behavior, not state.
- Infrastructure Ignorance: The domain core is decoupled from persistence, frameworks, and external tools.
- Logic Flow: The
elsekeyword is banned. Use guard clauses and early returns to minimize indentation.
Installation
Install the package via composer:
composer require phprise/http-connector
Usage
The http-connector is the Orchestrator of the HTTP system. It connects the specialized request atoms to the client atoms, acting as the main entry point for sending data through the pipe.
Standard Connector
The synchronous connector uses a Psr\Http\Client\ClientInterface to send requests.
use Phprise\Http\Connector\Connector; $connector = new Connector($client); $response = $connector->send($request);
Async Connector
The asynchronous connector uses an Http\Client\HttpAsyncClient to return promises.
use Phprise\Http\Connector\AsyncConnector; $connector = new AsyncConnector($asyncClient); $promise = $connector->send($request);
Evented Connector
A decorator that adds PSR-14 event support to the standard connector.
use Phprise\Http\Connector\EventedConnector; $connector = new EventedConnector($standardConnector, $eventDispatcher); $response = $connector->send($request);
Note
This atom is responsible only for orchestration. It does not know how to build a request or how to transmit bytes; it only delegates these tasks to specialized atoms.
Philosophy
We follow The OTAKU Manifesto: Fluid Structure Design.
- O - Own your Discipline (Be strict with yourself)
- T - Tools for Composition (Compose like Unix)
- A - Armor the Core (Protect the heart of the business)
- K - Keep Infrastructure Silent (Infrastructure is just a detail)
- U - Universal Language & Contracts (Speak the user's language via clear contracts)
Please read more about it in PHILOSOPHY.md.
License
MIT License
Free to use, modify, and distribute.