1. Go to this page and download the library: Download tyam/bamboo 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/ */
tyam / bamboo example snippets
// You must specify template base directory to the bamboo engine.
$basedirs = ['/your/template/dirs', '/come/here'];
$engine = new \tyam\bamboo\Engine($basedirs);
// Render the template with template variables. You get an output string.
$variables = ['title' => $this->getTitle(), 'content' => $this->getContent()];
$output = $engine->render('mytpl', $variables);
$respond->setOutput($output);
use tyam\bamboo\Engine;
use tyam\bamboo\VariableProvider;
class MyController implements VariableProvider
{
// This is the method declared abstract in VariableProvider and providing side contents.
public function provideVariables(string $template): array
{
// Here you provide side contents.
return [
'user' => $this->getUser(),
'notifications' => $this->getNotifications(),
'recommendations' => $this->getRecommendations()
];
}
public function action()
{
// Get domain result in some way.
$result = $this->callDomain();
// Pass $this as VariableProvider to bamboo engine.
$engine = new Engine(self::$basedirs, $this);
// Just bind domain result to the template.
$output = $engine->render('my/template', ['result' => $result]);
// Then output. Thanks to variable-pulling, the code is quite straight forward.
$this->response->output($output);
}
}
/* Store Subject header in a section */
$variables = ['user' => $user, 'confirmationUrl' => $confirmationUrl];
// Pass an empty array for sections.
$sections = new \ArrayObject();
$output = $engine->render('email/signup-confirm', $variables, $sections);
// Now we get Subject header and To header from sections
$mailer->setSubject($sections['Subject']);
$mailer->setTo($sections['To']);
$mailer->setBody($output);
$mailer->send();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.