PHP code example of arikaim / container

1. Go to this page and download the library: Download arikaim/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/ */

    

arikaim / container example snippets

 

use Arikaim\Container\Container;

$container = new Container();

 

$container['service'] = function() {
    echo "Service example";
};

$container->add('service_add',function() {
    echo "Service add example";
});


$container->add('date',function () {
    return new \DateTime();
});


$date = $container['date'];
echo $date->format('Y-m-d');



$container['config'] = "Config value";



$container->replace('service',function() {
     echo "Replace Service";
});


$servcie = $container->get('service');

if ($container->has('service')) {
    \\ Service exists
}