infocyph/intermix
最新稳定版本:5.34.02
Composer 安装命令:
composer require infocyph/intermix
包简介
A Collection of useful PHP class functions.
关键字:
README 文档
README
InterMix is a modern, lightweight PHP toolkit for developers who love class-oriented design, clean architecture, and fast execution. From dependency injection to dynamic macros, every utility is designed to just work — with minimal config and maximum control.
🚀 Key Features
- Dependency Injection (DI) — PSR-11 compliant container with:
- attribute-based injection
- scoped lifetimes
- lazy loading
- environment-specific overrides
- debug tracing & cache support
- Caching — Dual PSR-6 & PSR-16 compatible cache engine
- Fence — Enforce singleton-style class safety
- MacroMix — Dynamically extend objects or classes with macros
- Memoizer —
once()andmemoize()helpers for deterministic caching - Global Utilities — Like
pipe(),retry(),measure(),flatten(), and more
📦 Installation
composer require infocyph/intermix
Supported PHP versions:
| InterMix Version | PHP Version |
|---|---|
| 2.x.x and above | 8.2 or newer |
| 1.x.x | 8.0–8.1 compatible |
⚡ Quick Examples
🧱 Dependency Injection
use function Infocyph\InterMix\container; $c = container(); $c->definitions()->bind('now', fn () => new DateTimeImmutable()); echo $c->get('now')->format('c');
Enable autowiring with attributes:
$c->options()->setOptions( injection: true, methodAttributes: true, propertyAttributes: true );
Tag-based resolution:
$c->definitions()->bind('a', A::class, tags: ['service']); $c->definitions()->bind('b', B::class, tags: ['service']); foreach ($c->findByTag('service') as $svc) { $svc()->handle(); }
See full container guide at: 📖 https://intermix.readthedocs.io/en/latest/di/overview.html
🧬 Dynamic Macros
MacroTest::mix(new class { public function hello($name) { return "Hey, $name!"; } }); echo (new MacroTest)->hello('Ali'); // Hey, Ali!
🧠 once() Memoization
use function Infocyph\InterMix\Remix\once; $value = once(fn() => rand(1000, 9999)); // Only runs once per file+line
📚 Documentation
Full documentation available on ReadTheDocs:
🔗 https://intermix.readthedocs.io
Includes:
- ✅ Getting Started & Quickstart
- 📦 DI Container Guide (bindings, scopes, attributes, lifetimes)
- 🧩 Modules: Memoizer, Fence, MacroMix
- 🧪 Testing & Caching Tips
- 📘 PDF/ePub formats
✅ Testing
composer install
composer test
🤝 Contributing
Got ideas or improvements? Join us!
📂 Open issues 📬 Submit a PR — we welcome quality contributions
🛡 License
MIT Licensed — use it freely, modify it openly.
统计信息
- 总下载量: 5.76k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-04-15