Answer the question
In order to leave comments, you need to log in
Prompt PHP Template Engine
Good day to all. Please tell me a template engine in PHP
1) which has a URL Router
2) which did not appear yesterday and which, on the other hand, has not died yet
3) with a low entry threshold
Unfortunately, I am familiar with PHP insofar as, therefore, I would like something simpler .
I need to write a simple site, which at the beginning will not even work with a database, it's all static. But a template engine is needed, because the content of one of the divs will be different on each page and will be taken from a file in a specific folder.
Smarty, for example, is not suitable, because I did not find the URL Router on it. Or did I look badly?
Symfony is, I've heard, terribly complicated.
Tell me, good people, where to dig.
Thanks in advance.
Answer the question
In order to leave comments, you need to log in
Well, as if the task of url routera lies not on the template engine, but on the framework itself.
To make it easier, you can take any framework: Zend, Yii, Symphony, CI, etc.
You can easily attach a template engine to any of them.
PHP is a templating engine in itself. Moreover, the most flexible, powerful, customizable, extensible and productive of all possible template engines for PHP. This is a very strong point of this odious language, I recommend using it instead of crutches like Smarty, which migrated to PHP from other languages \u200b\u200bthat do not have such direct integration with the web.
What do you mean by url router? As far as I understand, this is a function that generates page addresses?
And how do you imagine its work, it also depends on the engine / framework of the site.
Both smarty and twig are extensible template engines - you can add your own functions to them.
symfony is a framework in general. In the second version there is twig support out of the box and there is a url router class. But if you have a site without a database, then I don’t see much point in dragging a framework.
The same twig, as far as I know, is screwed into silex is a microframework based on symfony.
habrahabr.ru/post/137328/
With a built-in router, maybe you'll like it? =)
> 1) which has a URL Router
A built-in transaction manager is not required? Then it's all done by PHP's built-in tools:
if ($url == Url::URL1) {
echo "Hello";
} else {
echo "World";
}
cakephp addresses go like
www.spotlar.in/controller/method/ :id
www.spotlar.in/sites/bax/4
UrlGenerator does not exist separately from the framework, for a small site I advise -
Silex + UrlGeneratorService + (if you really need a template engine) Twig
Of course, you can take a template engine separately, some script for routing separately, but it seems to me that the framework will be easier for a beginner. There will be no need to think about how best to tie the components together. Documentation, examples, established approaches, the framework community - all this will greatly help you get used to it faster.
I would recommend some microframework, for example F3 Framework ( article on Habré )
If you have a small website with static content, it may be easier and faster to write your own function or class. Fencing bicycles is certainly not good, but dragging a framework for the sake of two or three rules for routing is, in my opinion, even worse.
At the expense of templating engines, PHP has a wonderful short_open_tag option, which of course doesn’t fundamentally change anything, but as my experience shows, it’s much better than any smarty that only creates an extra load.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question