yaknet / dynlink
An enterprise-grade, high-performance PHP Dynamic Link Library (.ydl) engine for runtime modular linking, symbol resolution, digital signing, and in-memory execution.
v1.0.2
2026-08-20 02:05 UTC
Requires
- php: >=8.2
- ext-json: *
- ext-openssl: *
- ext-zlib: *
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.0 || ^11.0
Suggests
- ext-sodium: Recommended for high-performance Ed25519 digital signatures
- ext-zstd: Recommended for ultra-fast Zstandard compression
README
YakNet DynLink is an enterprise-grade, high-performance Dynamic Link Library (.ydl) and module runtime linker for PHP 8.2+. Inspired by C/C++ .dll and .so architectures, DynLink compiles PHP modules into single portable, compressed, and digitally-signed binary libraries that can be dynamically linked, loaded into memory, and executed at runtime without touching the physical filesystem.
🚀 Key Features & Performance Optimizations
- Single-Pass Fusion Bundler (
__ydl_bundle.php):- Compiles multiple classes into a single-pass executable virtual bundle, reducing cold loading overhead to near-instant execution.
- Native PHP 8.2+ Attributes:
- Modern
#[YdlExport('Calculator')],#[YdlService('PaymentProcessor')], and#[YdlHook]attribute annotations.
- Modern
- Security Sandbox & Capability System:
- Inspects and validates dynamic library code against strict security policies, blocking dangerous functions (
exec,system,shell_exec,eval).
- Inspects and validates dynamic library code against strict security policies, blocking dangerous functions (
- AES-256-GCM Payload Encryption:
- Distribute proprietary, encrypted commercial modules with military-grade authenticated encryption.
- Built-in Nanosecond Profiler & Telemetry:
DynLink::profile()delivers fine-grained metrics for cold load, dynamic link, and memory consumption.
- Ed25519 & HMAC Cryptographic Signatures:
- Tamper-proof module distribution with public-key verification.
- Virtual Memory Stream Wrapper (
ydl://):- Zero filesystem footprint at runtime.
🛠️ Installation
composer require yaknet/dynlink
⚡ Usage Examples
1. Modern PHP 8.2+ Attribute Exports
namespace MyPlugin; use YakNet\DynLink\Attributes\YdlExport; use YakNet\DynLink\Attributes\YdlService; #[YdlExport("Calculator")] #[YdlService("Calculator")] class Calculator { public function sum(float ...$nums): float { return array_sum($nums); } }
2. Packaging a Module
use YakNet\DynLink\DynLink; use YakNet\DynLink\Security\Ed25519Signer; DynLink::pack('./src/MyPlugin', './build/MyPlugin.ydl', [ 'compression' => 'gzip', 'fusion' => true, 'optimize' => true, 'signer' => new Ed25519Signer(), 'private_key' => $privateKey ]);
3. Loading & Invoking at Runtime
use YakNet\DynLink\DynLink; $lib = DynLink::load('build/MyPlugin.ydl', [ 'verify_signature' => true, 'public_key' => $publicKeyHex ]); $calculator = $lib->getService('Calculator'); echo $calculator->sum(10, 20, 30); // 60
4. Performance Profiling
use YakNet\DynLink\DynLink; $result = DynLink::profile('build/MyPlugin.ydl'); print_r($result['profile']->toArray());
🧪 Testing & Quality Assurance
# Run unit tests composer test # Run PHPStan static analysis (Level 9 - Maximum Strictness) composer analyze # Run benchmark suite php example/benchmark.php
📄 License
This library is open-source software licensed under the MIT License. Copyright © 2026 YakNet Bilişim.