PHP code example of crysalead / box

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

    

crysalead / box example snippets


$box = new Box();

$box->service('foo', new MyClass());

use MyClass;

$box->factory('foo', function($param1, $param2) {
	return new MyClass($param1, $param2);
});

Box::factory('foo', 'otherNamespace\MyClass');

$box->get('foo', $param1, $param2);

$box->wrap('foo', $param1, $param2);

$dependency = $wrapper->get($param1, $param2);