Download the PHP package dual-native/http-system without Composer
On this page you can find all versions of the php package dual-native/http-system. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dual-native/http-system
More information about dual-native/http-system
Files in dual-native/http-system
Package http-system
Short Description Framework-agnostic PHP library implementing the Dual-Native Pattern with CID validation, bidirectional linking, and zero-fetch optimization
License GPL-2.0-or-later
Informations about the package http-system
Dual-Native HTTP System
A framework-agnostic PHP library implementing the Dual-Native Pattern for synchronized Human Representation (HR) and Machine Representation (MR) content delivery with Content Identity (CID) validation, bidirectional linking, and zero-fetch optimization.
This library implements the Dual-Native Pattern as defined in the Dual-Native Core Specification and Whitepaper, providing a production-ready implementation of the 5 pillars: Resource Identity (RID), Content Identity (CID), Bidirectional Linking, Semantic Equivalence, and Cataloging & Discovery.
Features
- ๐ Framework-Agnostic: Works with WordPress, Laravel, Symfony, or standalone
- ๐ Content Identity (CID): SHA-256 based version validators for zero-fetch optimization
- ๐ Bidirectional Linking: Automatic navigation between HR and MR
- ๐ฆ Resource Catalog: Registry of dual-native resources with efficient discovery
- ๐ Safe Write Operations: Optimistic concurrency control with CID validation
- โ Semantic Equivalence: Validation that HR and MR represent the same content
- ๐๏ธ Dependency Injection: Clean architecture with pluggable adapters
- ๐งช Well-Tested: 14 PHPUnit tests (32 assertions) with 100% core coverage
Installation
Install via Composer:
Requirements
- PHP 8.0 or higher
- PSR-4 autoloading support
Quick Start
Basic Usage (Standalone)
WordPress Integration
See MIGRATION-GUIDE.md for complete WordPress plugin integration instructions.
Laravel Integration
Core Concepts
This library provides the business logic for the Dual-Native Pattern. When used in HTTP contexts, CIDs map to ETags for conditional requests (If-Match, If-None-Match), enabling 304 Not Modified responses for unchanged resources and 412 Precondition Failed for conflicting writes. See the WordPress plugin for a complete HTTP implementation example.
Content Identity (CID)
CIDs are SHA-256 hashes of canonical JSON representations, used as ETags for efficient caching:
Safe Write Operations
Prevent conflicting updates using optimistic concurrency control:
Resource Catalog
Maintain a registry of dual-native resources:
Bidirectional Links
Generate navigation links between HR and MR:
Architecture
The library follows a clean architecture with dependency injection:
Interfaces
EventDispatcherInterface: Framework-agnostic event dispatching
dispatch(string $eventName, ...$args): voidfilter(string $filterName, $value, ...$args)hasListeners(string $eventName): bool
StorageInterface: Framework-agnostic data persistence
get(string $key, $default = null)set(string $key, $value): booldelete(string $key): boolhas(string $key): bool
Adapters
Included:
WordPressEventDispatcher- Bridges to WordPressdo_action()/apply_filters()WordPressStorage- Bridges to WordPressget_option()/update_option()NullEventDispatcher- No-op implementation for testingInMemoryStorage- Array-based storage for testing
Create your own: Implement the interfaces for your framework (Laravel, Symfony, etc.)
Testing
The library includes a comprehensive test suite:
API Reference
DualNativeSystem
Constructor
Content Identity
Resource Management
Catalog
Links
Validation
Health Check
Configuration
Default configuration:
Events
When using an event dispatcher, the library dispatches these events:
dual_native_system_initialized- System initializeddual_native_created_resource- Resource createddual_native_bidirectional_links- Links generateddual_native_link_header- Link header generateddual_native_computed_cid- CID computeddual_native_catalog_updated- Catalog updated
Performance
- Zero-Fetch Optimization: 90%+ reduction in unchanged content transfers
- CID-based Caching: Efficient conditional requests with ETags
- Bandwidth Savings: 83%+ reduction compared to full content fetching
Use Cases
- WordPress Sites: Add machine-readable APIs to existing WordPress content
- Headless CMS: Provide synchronized HR/MR for decoupled architectures
- API Versioning: Use CIDs for efficient cache validation
- Content Distribution: Efficient content synchronization across systems
- Real-time Systems: Detect content changes without fetching full resources
Documentation
- MIGRATION-GUIDE.md - Integrating with WordPress plugin
- Packagist - Package information
- GitHub - Source code
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
GPL-2.0-or-later - GNU General Public License v2.0 or later
Credits
Developed by the Dual-Native Team
Support
- Issues: GitHub Issues
- Email: [email protected]