Search by

drago-ex / simple

accgit

Easy configuration for single-page sites.

Package info

github.com/drago-ex/simple

pkg:composer/drago-ex/simple

Statistics

Installs: 192

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v2.1.0 2026-10-17 13:17 UTC

This package is auto-updated.

Last update: 2026-10-19 07:06:42 UTC


README

Easy configuration for single-page sites.

License: MIT PHP version Tests Coding Style

Requirements

  • PHP >= 8.3, < 9
  • Nette Framework
  • Composer

Installation

composer require drago-ex/simple

Knowledge

Latte

Drago\Simple\Latte is a Latte engine that passes $basePath to every template:

use Drago\Simple\Latte;

$latte = new Latte;
$latte->setTempDirectory(__DIR__ . '/../temp/latte');
<link rel="stylesheet" href="{$basePath}/css/style.css">

Traits

Session Trait

use Drago\Simple\Base\Session;

// The session is created from the current request on the first call and then reused
$this->session();

Message Trait

use Drago\Simple\Base\Message;

// Save a message for the next page
$this->flashMessage('Message...');

// Read the message; it is removed after reading, so it is shown only once
$this->getFlashMessage();

Response Trait

use Drago\Simple\Base\Response;

// Redirect to a URL; the script stops after the redirect is sent
$this->redirect('#');

Controller Example

use Drago\Simple\Base\Message;
use Drago\Simple\Latte;

final class Home
{
	use Message;

	public function __construct(
		private Latte $latte,
	) {
	}


	public function render(): void
	{
		$this->latte->render(__DIR__ . '/templates/Home.latte', [
			'message' => $this->getFlashMessage(),
		]);
	}
}
<p n:if="$message">{$message}</p>

Forms

Install Nette Forms via Composer:

composer require nette/forms

Register the form tags in Latte:

$latte->addExtension(new Nette\Bridges\FormsLatte\FormsExtension);

Translator

Install the Translator via Composer:

composer require drago-ex/translator

Create the translator with your translation directory and choose the language from the request:

use Drago\Localization\Options;
use Drago\Localization\Translator;
use Drago\Localization\TranslatorFinder;
use Nette\Http\RequestFactory;

$options = new Options;
$options->translateDirs = [__DIR__ . '/locale'];

$translator = new Translator($options, new TranslatorFinder);
$lang = (new RequestFactory)->fromGlobals()->detectLanguage(['en', 'cs']) ?? 'en';
$translator->setTranslate($lang);

$latte->addExtension(new Latte\Essential\TranslatorExtension($translator->translate(...)));

Translations are then available in templates as {_'Hello'} or {$text|translate}.

Prepared Package for Simple Project

https://github.com/drago-ex/simple-project