lazy-container travis-ci Packagist phpunit

Lazy loading for interop container

3 years after

Lazy-Container Build Status

Lazy loading for interop container

Get lazy loadable object from any interop container! Powered by Proxy Manager

Usage

// Build LazyLoadingValueHolderFactory as you want
$lazyLoadingFactory = new ProxyManager\Factory\LazyLoadingValueHolderFactory();

// Prepare you favorite container
$pimple = new Pimple\Container();
$pimple['service'] = function ($container) {
    return new HeavyService($container->get('dependency'));
};

// Create map (service name => class name) where you choose which services should be lazy loaded
$classMap = ['service' => HeavyService::class];

// Put all things to LazyContainer
$container = new LazyContainer($pimple, $lazyLoadingFactory, $classMap);

// Use LazyContainer exactly same like other interop container (thanks for interface)
$service = $container->get('service');

// Now $service is a proxy, so HeavyService wasn't created yet

// After first usage of $service is real HeavyService!
$result = $service->doSomething();

Installation

You can install this package through Composer:

composer require snapshotpl/lazy-container

Related Repositories

lazy-load-xt

lazy-load-xt

Lazy load XT is a jQuery plugin for images, videos and other media ...

lazy-ads

lazy-ads

Deliver synchronous ads asynchronously, without modifying the ad code. Also, con ...

container-interop

container-interop

Containers interoperability ...

jquery.lazy

jquery.lazy

A lightweight, fast, feature-rich, powerful and highly configurable delayed cont ...

ng-lazy-image

ng-lazy-image

Angular directive for loading responsive image when container (which is preventi ...


Top Contributors

snapshotpl abdala

Releases

-   1.0.0 zip tar