1. Go to this page and download the library: Download wpshop/container 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/ */
wpshop / container example snippets
namespace YourVendor\YourProduct;
use WPShop\Container\Psr11\Container;
/**
* @return Container
*/
function theme_container()
{
static $container;
if (!$container) {
$init =
use WPShop\Container;
use YourVendor\YourProduct\Maintanance;
use YourVendor\YourProduct\Options;
return function ($config) {
$container = new Container\ServiceRegistry([
AssetsProvider::class => function($c) {
return new AssetsProvider($c[Maintanance::class]);
},
Maintanance::class => function($c) {
return new Maintanance($c[Options::class]);
},
Options::class => function () use ($config) {
return new Options($config);
}
]);
do_action('your_vendor/your_product/init_container', $container);
return $container;
}