1. Go to this page and download the library: Download infocyph/intermix library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
infocyph / intermix example snippets
use function Infocyph\InterMix\container;
$c = container();
$c->definitions()->bind('now', fn () => new DateTimeImmutable());
echo $c->get('now')->format('c');
use Infocyph\InterMix\DI\Container;
use Infocyph\InterMix\DI\Support\LifetimeEnum;
$c->bindFactory(
Database::class,
static fn (Container $container): Database => new Database(
$container->get(DatabaseConfig::class),
),
LifetimeEnum::Singleton,
tags: ['infrastructure'],
);
// Equivalent fluent lifetime selection:
$c->factory(
RequestContext::class,
static fn (Container $container): RequestContext => new RequestContext(
$container->get('request.id'),
),
)->scoped();
MacroTest::mix(new class {
public function hello($name) {
return "Hey, $name!";
}
});
echo (new MacroTest)->hello('Ali'); // Hey, Ali!
use Infocyph\CacheLayer\Cache\Cache;
$pool = Cache::memory('intermix.definitions'); // or any PSR-6 pool
$c->definitions()->enableDefinitionCache($pool, generation: 'deployment-2026-08');
$report = $c->definitions()->warmDefinitionCache();
use Infocyph\InterMix\DI\Support\FactoryDefinition;
use Infocyph\InterMix\DI\Support\ServiceReference;
$path = __DIR__ . '/var/intermix.compiled.php';
// Explicit recipes can be executed dynamically and compiled safely.
$c->bind('mailer', FactoryDefinition::construct(Mailer::class, [
new ServiceReference(Logger::class),
'transactional',
]));
// Build time, after every definition and option is registered.
$c->compileTo($path);
$report = $c->compilationReport();
// Runtime, after performing the same registration.
$c->useCompiled($path);