Frequently Asked Questions
The most frequently asked questions.
Table of Contents
- General Questions
- Library issues
- Support issues
- OPT and frameworks
1. General questions
- What is a template engine?
- A template engine is a special script that manages the generation of the HTML code on your website. Its main task is to separate the application logic (the part that processes the data) from their presentation (the way how they are displayed). The script passes the generated data to the template engine and assumes that the template engine knows, how to display them propertly. The important issue that concerns template engines are template files. They might be written in pure PHP or in a special language that is supposed to make writing and managing them easier.
- How a template engine could help me?
- Having the application logic separated from the data presentation, you can distribute the application development over all your team much easier. The programmers may concentrate on the algorithms and the application structure, whereas the webmasters develop the HTML code independently, without worrying that they accidentaly break an important piece of the code. The template engine allows also to create a skin system. Each skin is a separate template set and the application can choose between them. A good template engine should also simplify the template engine writing by offering a set of extra tools and features.
- Why Open Power Template?
- There are a lot of template engines written for PHP. OPT is not an amateur project written in a week, but a library designed on a five-year template engine experience and practical observations of real projects. It offers the performance, features and a convenient syntax based on XML. We want the template designer to feel comfortable and focus on what to display, not how it is supposed to work.
- Why a template engine? PHP is the best.
- In fact, pure PHP is horrible to write templates. Note that even frameworks provide you a set of extra helpers and functions that perform many common tasks for you and the necessary logic, so they could be also considered as template engines that use PHP as the template language. However, we encourage you to think why you are writing your websites in PHP or Ruby, not C++ or assembler? Right - that languages were too complex for most of the website-related tasks. PHP was originally developed as a “hypertext preprocessor”, but it was a long time ago. Nowadays, if provides more and more features useful rather in writing real-world application logic than writing HTML templates - it is simply too verbose and redundant. We are using the template engines with their own template language for a long time and they often helped us a lot with complex problems. There are two keys to the success - you must use a proper template language that really simplifies the common template problems rather than being a simple copy of PHP imperative control structures like
foreach. Moreover, you have to forget about old habits and introduce a strict rigour. Even in OPT it is possible to write messy templates, but contrary to many other solutions - there is also an alternative way.
- Is Open Power Template 1 ready for production use?
- Yes. OPT 1 is a mature library and has been used in many real-world projects so far. You must only know that it is not developed anymore.
- Is Open Power Template 2 ready for production use?
- Yes. Open Power Template 2.0.0 has been released in July 2009 and since then it is considered as stable.
- Does Open Power Template work on PHP4?
- No, it never worked on this version and the support is not planned.
- Does Open Power Template work on PHP5?
- OPT 1.x should work on all the PHP5 versions available today. OPTv2 does not support the oldest releases, 5.0.x and 5.1.x due to some missing features and stability problems. This version is intended to work with PHP 5.3.x, but can be also run without any problems on PHP 5.2.x.
- Does Open Power Template work on PHP6?
- Yes, it should. From time to time, we are testing OPTv2 on this version and sometimes we encounter some minor problems that do not crash the library. Note that the current PHP6 code is under heavy development and it is hard to optimize the code for this branch now. However, once it will be much closer a stable release, we will do our best to make OPTv2 work on it.
How fast is Open Power Template?
Although the source code of OPT is quite big, most of it is loaded and used from time to time only. The required part is much smaller and we constantly optimize the library, analyzing the code and using benchmarks to determine, what should be improved. You can see one on our wiki page and any suggestions or ideas are welcome on our discussion board.
How OPT is faster than PHP-based template engines?
Many programmers claim that extra template language always means extra load. This does not have to be true in many cases. Open Power Template, like many template engines, compiles the templates to pure PHP code. During the execution, the only difference from technical point of view is that OPT also checks, whether the template has been modified.
Furthermore, the compiler is not limited by the code readability. It can generate ugly, but faster output or even solve some issues at the compilation stage. At the same time, PHP-based template engines must use massive OOP techniques to perform the same task.
4. Support issues
- I need a proper support. Is OPT able to provide it?
- Yes, certainly. Invenzzia runs several community tools that allow you to get help and learn more about OPT. We are constantly improving the user manual, API reference and tutorials. Moreover, we help solving problems on our discussion board and try also to help the projects that use OPT.
- Where can I find a tutorial for OPT 1.x?
- Unfortunately, for OPT 1, all the tutorials are available in Polish language only and due to the incoming release of OPT 2, the translations are not planned. However, there is a complete English manual.
- Where can I find a tutorial for OPT 2.x?
- For example on our website in Resources. Visit also our wiki.
- Where can I find extensions and add-ons for OPT?
- The list of the currently released add-ons can be found on our wiki.
5. OPT and frameworks
- Is OPT developed to be integrated with frameworks?
- Yes, the goal of OPT is to provide presentation features for frameworks and a framework-friendly API.
- Are there planned any official plugins for frameworks?
- Yes. On our SVN, you can find a port for Zend Framework. There are also two community-driven ports for Kohana and CakePHP.