PHP code example of bulldog / container

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

    

bulldog / container example snippets



tainer = new Bulldog\Container;

$value = $container->set('id', 'value');
echo $value;
// value

$result = $container->has('id');
var_dump($result);
// bool(true)

$value = $container->get('id');
echo $value;
// value


tainer = new Bulldog\Container;

class Example
{
    public function test()
    {
        echo 'it works!';
    }

}

// Using a closure
$container['service'] = function() {
    return new Example;
};

$service = $container['service'];
$service->test();
// it works!

// Storing an object (not lazy loaded)
$container['service'] = new Example;
$service = $container['service'];
$service->test();
// it works!



include 'vendor/autoload.php';

$container = new Bulldog\Container;

class Required
{
    private $test = "Hello";

    public function getTest()
    {
        return $this->test;
    }
}

class Example
{
    private $   return new Required;
};

$container['example'] = function($c) {
    return new Example($c['
bash
php-cs-fixer fix ./src
php-cs-fixer fix ./tests