abmmhasan/intermix

This package is abandoned and no longer maintained. The author suggests using the infocyph/intermix package instead.

A lightweight PHP DI container, invoker, serializer, and utility toolkit.

Maintainers

Package info

github.com/infocyph/InterMix

pkg:composer/abmmhasan/intermix

Statistics

Installs: 74

Dependents: 0

Suggesters: 0

Stars: 13

Open Issues: 0

7.2 2026-05-22 14:08 UTC

README

Security & Standards Packagist Downloads License: MIT Packagist Version Packagist PHP Version GitHub Code Size Documentation

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 community
MIT Licensed
DocumentationSecurityCode of ConductContributingReport | Request | Suggest