Nette PHP Framework: Introduction

imageIt was nice to find the website of this framework quite randomly in the second half of the business hours. New frameworks are rare, and even more rarely you come across mechanisms that are liked at first sight. Therefore, I would like to share my discovery with you.

First, I liked its name Nette right away. It's almost like a Latte. Only Nette as it turned out later is the Latte that has its own built-in template engine. Oh.

Second, at first view it created an impression of something new and advanced (they are almost as thoughts of the PHP team, pluging in the genius language the traits, and forgetting the boring Unicode):
  • HTML5
  • PHP 5.3
  • Built-in HTML template macros
  • Context-Aware Escaping technology
  • Configurations in the curious NEON format, on basis of which is generated PHP code
  • Own implementation of the base class for objects Nette \ Object
  • Events and subscription
  • Callbacks
  • New streaming protocol safe :/ / for an atomic access to the file system

Third, as it turned out, Nette is a national framework. This framework is written by Czech programmer David Grudl quite a long time ago in 2004. However, the code became publicly available just in 2008. According to the information on this site, Nette is the most used and popular PHP framework in the Czech Republic. In particular, the official website of President, Václav Klaus is based on its framework.

I should say that in the framework description were met many interesting, amusing, and most importantly, new things that I would like to learn more. Since it's not a review of the framework, but only the first introduction I will highlight the main points that I could understand.

Working with forms

There is supported a validation on the client side (JavaScript), and as on the server side. There is a built-in protection against attacks (XSS and CSRF). There are available a few rendering modes of form. Internationalization (i18n) allows you to create multilingual forms.

In general, the functionality and structures are similar to the Zend Framework forms, but somehow it looks more easy and fresh. Instead of horrible Zend decorators are more understandable wrappers at first glance.

Own template engine

Latte with its clever macros that are built-in into HTML tags looks much more readable than the native PHP.

It is important that the template engine escapes variables by default when is outputted to a page, which does not allow forgetting about it. There is mentioned some clever Context-Aware Escaping technology that automatically allows escaping the different variables. Actually, there are enough the high-profile names in this framework. But maybe it's not so scary.

The template engine should be fast, because it compiles the templates in a pure PHP code, and stores them in cache.

In general, the template engine is simpler and more intuitive compared to Smarty.


They are very convenient. It is proposed to write them in the format of NEON. A very interesting format, probably it will add some readability to the huge trees of configurations. They could be divided into the files and merged with priorities. One of the features that allows using of this framework in large projects.

In addition

There is a mechanism for the sessions with the support of the sections in order to avoid naming conflicts in large projects. It has sophisticated caching system with different types of storage for the values, tags and the priorities. The directories can be indicated for the Avtoloader, which will scan them for the presence of classes and interfaces, and it will store this information in the cache.

Instead of conclusion

I should say that the first impression sometimes could be delusive. I sincerely hope that this is not the case.

Here is the website of framework:
ZimerMan 10 march 2012, 14:48
Vote for this post
Bring it to the Main Page


0 alexg June 3, 2014, 1:33
Nice article! How's the performance? I see you guys have good response time here. What are you using behind the scene?
+1 ZimerMan June 3, 2014, 8:21
via AB syntetic tests, with c=20 and n=500:

Framework Req/Sec
Phalcon 822.96
Slim 399.83
Kohana 217.34
Code Igniter 187.78
Silex 179.01
Laravel 135.9
YII 123.5
Fuel PHP 116.34
Hazaar MVC 103.53
Zend 1 103.02
Cake PHP 54.97
Nette 53.48
Symfony2 39.22
Zend 236.1

So, it's not that good as want to be, but it's at the beginning of his way.

Leave a Reply

Avaible tags
  • <b>...</b>highlighting important text on the page in bold
  • <i>..</i>highlighting important text on the page in italic
  • <u>...</u>allocated with tag <u> text shownas underlined
  • <s>...</s>allocated with tag <s> text shown as strikethrough
  • <sup>...</sup>, <sub>...</sub>text in the tag <sup> appears as a superscript, <sub> - subscript
  • <blockquote>...</blockquote>For  highlight citation, use the tag <blockquote>
  • <code lang="lang">...</code>highlighting the program code (supported by bash, cpp, cs, css, xml, html, java, javascript, lisp, lua, php, perl, python, ruby, sql, scala, text)
  • <a href="http://...">...</a>link, specify the desired Internet address in the href attribute
  • <img src="http://..." alt="text" />specify the full path of image in the src attribute