1. Go to this page and download the library: Download brightnucleus/injector 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/ */
brightnucleus / injector example snippets
class BookReader
{
/** @var BookInterface */
protected $book;
public function __construct(BookInterface $book)
{
$this->book = $book;
}
public function read()
{
echo $this->book->getContents();
}
}
$bookReader = $injector->make('BookReader');
// This will now echo the result of LatestBestseller::getContents().
$bookReader->read();
// Format:
// '<class/interface>' => '<concrete class to instantiate>',
Injector::STANDARD_ALIASES => [
'BrightNucleus\Config\ConfigInterface' => 'BrightNucleus\Config\Config',
]
// Format:
// '<class/interface>' => '<concrete class to instantiate>',
Injector::SHARED_ALIASES => [
'ShortcodeManager' => 'BrightNucleus\Shortcode\ShortcodeManager',
]
// Format:
//
// '<alias to provide argument for>' => [
// '<argument>' => '<callable or scalar that returns the value>',
// ],
Injector::ARGUMENT_DEFINITIONS => [
'PDO' => [
'dsn' => $dsn,
'username' => $username,
'passwd' => $password,
]
]