PHP code example of wpshop / container

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;
}




/**
 * @see https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata
 */

namespace PHPSTORM_META {
	override( \Psr\Container\ContainerInterface::get( 0 ), map( [

	] ) );
}

 



use YourVendor\YourProduct\AssetsProvider;
use function YourVendor\YourProduct\theme_container;

t();


core
  |- init-container.php
  |- config.php
src
  |- AssetsProvider.php
  |- Maintanance.php
  |- Options.php
  |- functions.php
.phpstorm.meta.php
composer.json
functions.php
readme.txt
style.css

... (other theme files)