Lemric BatchProcessing is built around PHP-FIG standards for maximum interoperability.
| PSR | Title | Where it is used |
|---|---|---|
| PSR-3 | Logger Interface | All long-running components implement LoggerAwareInterface |
| PSR-6 | Caching Interface | CachedJobExplorer decorator |
| PSR-11 | Container Interface | ContainerJobRegistry, ContainerStepLocator, ContainerJobLocator |
| PSR-14 | Event Dispatcher | All Event\* classes; injected into AbstractJob/AbstractStep |
| PSR-16 | Simple Cache | SimpleCacheJobExplorer decorator |
Components that perform long-running work expose setLogger() (e.g.
AbstractJob::setLogger(), AbstractStep::setLogger()):
$step->setLogger($logger);
$repository->setLogger($logger); // when supportedWhen a logger is provided, the framework emits structured log messages for:
- Job/step lifecycle transitions
- Retry attempts (via the retry listener)
- Skip events
- Chunk commit/rollback events
The Lemric\BatchProcessing\Listener\Logging namespace ships ready-made
PSR-3 logging listeners (LoggingChunkListener, LoggingItemReadListener,
…).
Resolve jobs from any PSR-11 container:
use Lemric\BatchProcessing\Registry\ContainerJobRegistry;
use Psr\Container\ContainerInterface;
$registry = new ContainerJobRegistry($container);
$job = $registry->getJob('importOrdersJob');ContainerStepLocator provides the same lookup pattern for partition workers,
and ContainerJobLocator is a lazy locator variant.
Inject any PSR-14 dispatcher into AbstractJob/AbstractStep via
setEventDispatcher() (or via the builder's eventDispatcher() method):
use Psr\EventDispatcher\EventDispatcherInterface;
use Lemric\BatchProcessing\Event\AfterJobEvent;
$dispatcher->addListener(
AfterJobEvent::class,
function (AfterJobEvent $event): void {
$execution = $event->getJobExecution();
$logger->info('Job finished', [
'status' => $execution->getStatus()->value,
'reads' => array_sum(array_map(
fn($s) => $s->getReadCount(),
$execution->getStepExecutions()
)),
]);
}
);See Listeners & Events for the full event catalogue.
Decorate the explorer with caching:
use Lemric\BatchProcessing\Explorer\{CachedJobExplorer, SimpleCacheJobExplorer};
// PSR-6 (CacheItemPoolInterface)
$explorer = new CachedJobExplorer($simpleExplorer, $psr6Cache);
// PSR-16 (SimpleCache)
$explorer = new SimpleCacheJobExplorer($simpleExplorer, $psr16Cache);