1. Go to this page and download the library: Download exts/canister 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/ */
exts / canister example snippets
use Canister;
$container = new Canister;
$container['my-key-value'] = 'accessed anywhere';
echo $container->get('my-key-value'); // or $container['my-key-value'];
class Example
{
public function foo() {
return 'bar';
}
}
$example = $container->get(Example::class);
echo $example->foo(); // -> 'bar'
class Test implements TestInterface {
public function example() {
return 'example';
}
}
class TestExample {
public function __construct(TestInterface $test) {
$this->test = $test;
}
public function testing() {
return $this->test->example();
}
}
$container->alias(TestInterface::class, Test::class);
$test_example = $container->get(TestExample::class);
echo $test_example->testing(); // -> 'example'