1. Go to this page and download the library: Download dhii/containers 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/ */
dhii / containers example snippets
// Retrieve factories and extensions from respective files, and create a service provider with them
$factories = / Perhaps retrieve service providers from other modules and aggregate them
$provider = new CompositeCachingServiceProvider([$appProvider, $moduleProviderA, $moduleProviderB]);
$proxyContainer = new ProxyContainer(); // A temporary parent container for lookup delegation
$container = new DelegatingContainer($provider, $proxyContainer); // Container with application configuration
$appContainer = new CompositeContainer([ // The application's container
$dbContainer, // <-- Perhaps another container with configuration from DB
$container, // <-- The main container with merged configuration from modules
]);
$appContainer = new CachingContainer($appContainer); // Add caching, so that each service definition is only invoked once
$proxyContainer->setInnerContainer($appContainer); // Switch lookup to the application's main container, making it available in service definitions
// Retrieve cached configuration aggregated from various modules and other sources, sucha as the database or a remote API
$appContainer->get('my-service');