Easy configuration for single-page sites.
- PHP 8.1 or higher
- composer
- Latte: amazing template engine for PHP
- RobotLoader: comfortable autoloading
- Nette HTTP Component
- Tracy - PHP debugger
composer require drago/simple
use Drago\Simple\Base\Session
// Get session.
$this->session();
use Drago\Simple\Base\Message;
// Save message.
$this->flashMessage('Message...');
// Print message.
$this->getFlashMessage();
use Drago\Simple\Base\Response;
$this->redirect('#');
final class Home
{
private Latte\Engine $latte;
public function __construct(Latte\Engine $latte)
{
$this->latte = $latte;
}
}
public function render(): void
{
$this->latte->render(__DIR__ . '/path/to/dir/template.latte');
}
public function render(): void
{
$this-flashMessage('message...');
$message['message'] = $this->getFlashMessage();
$this->latte->render(__DIR__ . '/path/to/dir/template.latte', $message);
}
<p n:if="$message">{$message}</p>
{$basePath}
Install via composer.
composer require nette/forms
Forms latte macro.
$latte->onCompile[] = function () use ($latte) {
FormMacros::install($latte->getCompiler());
};
Install via composer.
composer require drago-ex/translator
Translator property.
private array $lang = ['en', 'cs'];
Translator language detect.
$translator = new Translator(__DIR__ . '/locale');
$translator->setTranslate((new RequestFactory())->fromGlobals()
->detectLanguage($this->lang)
);
Translator latte filter.
$latte->addFilter('translate', function ($message) use ($translator) {
return $translator->translate($message);
});