PHP code example of calderawp / caldera-containers
1. Go to this page and download the library: Download calderawp/caldera-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/ */
calderawp / caldera-containers example snippets
$container = new \calderawp\CalderaContainers\Service\Container();
$container->bind( 'std', function (){
$obj = new \stdClass();
$obj->foo = rand();
return $obj;
});
//$obj1->foo !== $obj2->foo
$obj1 = $container->make('std');
$obj2 = $container->make('std');
$container = new \calderawp\CalderaContainers\Service\Container();
$obj = new \stdClass();
$obj->foo = rand();
$container->singleton( 'std', $obj );
//$obj1->foo === $obj2->foo
$obj1 = $container->make('std');
$obj2 = $container->make('std');