abmmhasan / intermix
A lightweight PHP DI container, invoker, serializer, and utility toolkit.
Requires
- php: >=8.3
- opis/closure: ^4.5
- psr/cache: ^3.0
- psr/container: ^2.0
Requires (Dev)
- infocyph/phpforge: dev-main
Suggests
- ext-mbstring: Recommended for development tools output formatting (Pest/Termwind)
- infocyph/cachelayer: Optional cache adapters for InterMix definition cache integration (PSR-6)
- dev-main
- 7.2
- 7.1.1
- 7.1
- 7.0
- 6.0
- 5.35.1
- 5.35
- 5.34.02
- 5.34.1
- 5.34
- 5.33.11
- 5.33.1
- 5.33
- 5.32.1
- 5.32
- 5.31.1
- 5.31
- 5.3.1
- 5.3
- 5.2.1
- 5.2
- 5.1
- 5.0.01
- 5.0
- 4.02
- 4.01.1
- 4.0
- 3.01.5
- 3.01.4
- 3.01.3
- 3.01.2
- 3.01.1
- 3.01
- 3.0
- 2.00.2
- 2.00.1
- 2.0
- 1.08.7
- 1.08.6
- 1.08.5
- 1.08.4
- 1.08.3
- 1.08.2
- 1.08.1
- 1.08
- 1.07.3
- 1.07.2
- 1.07.1
- 1.06.01
- 1.06
- 1.05.3
- 1.05.2
- 1.05.1
- 1.05
- 1.04
- 1.03
- 1.02
- 1.01.01
- 1.01.0
- 1.0.0
- dev-feature/di-update
This package is auto-updated.
Last update: 2026-05-22 14:23:15 UTC
README
InterMix is a modern, lightweight PHP toolkit for developers who value class-oriented design, clean architecture, and fast execution. It combines dependency injection, serialization, macro-style extensibility, and helper utilities with minimal config and maximum control.
Global helper functions are optional in
v2: core APIs are namespaced and helper loading is opt-in.
Key Features
- Dependency Injection (DI) — PSR-11 compliant container with:
- attribute-based injection
- scoped lifetimes
- lazy loading
- environment-specific overrides
- debug tracing & definition-cache integration via assignable PSR-6 pool
- Serializer — Closure-aware value serialization and resource handlers
- Fence — Enforce singleton-style class safety
- Remix — Fluent traits, proxies, and global helper functions
- MacroMix — Dynamically extend objects or classes with macros
- Global Utilities — Like
pipe(),retry(),measure()and more
Installation
composer require infocyph/intermix
Optional global helpers:
require_once __DIR__ . '/vendor/infocyph/intermix/src/functions.php';
Supported PHP versions:
| InterMix Version | PHP Version |
|---|---|
| 2.x.x and above | 8.3 or newer |
| 1.x.x | 8.0-8.2 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://docs.infocyph.com/projects/intermix/di/overview.html
Dynamic Macros
MacroTest::mix(new class { public function hello($name) { return "Hey, $name!"; } }); echo (new MacroTest)->hello('Ali'); // Hey, Ali!
Definition Cache (Injectable)
use Psr\Cache\CacheItemPoolInterface; $pool = /* any PSR-6 pool, e.g. from infocyph/cachelayer */; $c->definitions()->enableDefinitionCache($pool, cacheRuntimeObjects: false);
Compiled Resolvers
$path = __DIR__ . '/var/intermix.compiled.php'; // build-time: generate compiled resolver map $c->compileTo($path); // runtime: activate compiled resolver map explicitly $c->useCompiled($path); // optional one-step build + activate $c->compileTo($path, load: true);
Signed Serialization
$signed = \Infocyph\InterMix\Serializer\ValueSerializer::signed($_ENV['APP_KEY']); $token = $signed->encode(['user_id' => 1]); $payload = $signed->decode($token);
Testing
composer install
composer test
Security
Protected by PHPForge — an automated quality and security gate for PHP projects.
Made with ❤️ for the PHP communityMIT Licensed
Documentation • Security • Code of Conduct • Contributing • Report | Request | Suggest