abmmhasan / oof
A Collection of useful PHP class functions.
Requires
- php: >=8.2
- opis/closure: ^4.3
- psr/cache: ^3.0
- psr/container: ^2.0
- psr/simple-cache: ^3.0
Requires (Dev)
- captainhook/captainhook: ^5.24
- laravel/pint: ^1.20
- pestphp/pest: ^3.7
- rector/rector: ^2.0
- symfony/var-dumper: ^7.2
Suggests
- ext-apcu: For APCu-based caching (in-memory, per-process)
- ext-memcached: For Memcached-based caching (distributed, RAM)
- ext-pdo: For SQLite-based caching (file-based, portable)
- ext-redis: For Redis-based caching (persistent, networked)
- ext-sqlite3: For SQLite-based caching (file-based, portable)
This package is auto-updated.
Last update: 2025-06-22 10:54:43 UTC
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.