qiq / qiq
Provides a TemplateView implementations using PHP itself as the templating language, and an optional lightweight template markup.
Installs: 79 784
Dependents: 4
Suggesters: 0
Security: 0
Stars: 27
Watchers: 3
Forks: 5
Open Issues: 0
Requires
- php: ^8.1 | ^8.2 | ^8.3
- laminas/laminas-escaper: ^2.0
- psr/container: ^2.0
Requires (Dev)
- pds/composer-script-names: ^1.0
- pds/skeleton: ^1.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^10.0
- pmjones/php-styler: 0.x-dev
- symfony/finder: ^6.3
README
This package provides a PHP 8.1+ implementation of the
TemplateView
pattern using PHP itself as the templating language, along with an optional
{{ ... }}
syntax for concise escaping and helper use.
Documentation
Read the docs at https://qiqphp.com.
Background
I don't like compiled templates or specialized template languages. Smarty, Twig, etc. are all just too heavy-handed. I don't need a new language, and I don't need to "secure" my templates against designers on my team. I am generally happy with plain PHP as a template language.
However, I do find escaping tedious -- necessary, and easy enough, but tedious. A template helper to output escaped HTML, like this ...
<?= $this->h($var) ?>
... is not that bad -- but even so, it could be a little easier. Imagine this little bit of syntax sugar:
{{h $var }}
All that happens is that {{h ... }}
is replaced with <?= $this->h(...) ?>
.
Once that is in place, it becomes easy to support helpers, control structures,
and other code, all while keeping native PHP as the fallback syntax, because
the {{ ... }}
tags are essentially stand-ins for PHP tags.
Qiq really is PHP -- just with some syntax sugar when you want it.
History
Qiq's relatives include ...
- The Savant family:
- Solar_View
- Aura.View
- Laminas View (nee Zend_View)
This package is more closely related to Aura.View than to the pre-Composer versions of Savant, but does reintroduce the Savant compiler hook ideas.