📜 ⬆️ ⬇️

Nette PHP Framework: first acquaintance

Nette Framework Logo It was very pleasant to accidentally discover the site of this framework in the second half of the working day. New frameworks appear rarely, and even more rarely come across mechanisms that like at first sight. I didn’t find the description of Nette on Habré, so I hurried to share my find with you.

First, I immediately liked the name. Nette. It is almost like Latte. Only Nette. As it turned out later, there is Latte - its own built-in budding template engine. Wow.

Secondly, a cursory examination immediately gave the impression of something advanced and fresh (almost like the thoughts of the PHP team, which embeds trait into the language of brilliant beauty and has forgotten about boring Unicode):

Thirdly, as it turned out, Nette is a “national framework”. It is not often meet such a phrase. The framework is written by Czech programmer David Grudel. And it was written, as it turns out, quite a long time ago - in 2004. However, in open access code hit only in 2008. In accordance with the information on the site, Nette is the most used and popular PHP framework in the Czech Republic. In particular, on its basis the site of the country's president, Václav Klaus, was made. Pretty loud.

It must be said that in the description of the framework there were many interesting and funny, and most importantly, fresh things that I would like to learn more. But since this is not a review of the framework, but only a first acquaintance (and besides it is already 2 nights), I will confine myself to only the main points that I was able to clarify and which I had time for zanteresovatsya.
')

Working with forms


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

In general, in terms of functionality and constructions, it is similar to the Zend Framework forms, but somehow it is more easily and fresh. Instead of scary Zendovsky decorators - more understandable at first glance wrappers .

Own template engine


Latte . With tricky macros embedded in HTML tags. In appearance, much more readable than native PHP.

It is important that the template template escapes variables by default when outputting to the page, which does not allow to forget about it. Mentioned is some clever Context-Aware Escaping technology that allows you to automatically escape various variables correctly. Actually, there are enough loud names in this framework. But maybe this is not so scary.

The template engine must be fast, as the template compile into pure PHP code and stores them in the cache.

In general, the template engine is simpler and easier to understand than Smarty.

Configs


Convenient configs. It is proposed to write them in the NEON format. A rather curious format is likely to add readability to huge configuration trees. Configs can be divided into files and merge with priorities. One of the features that allows the use of this framework in large projects.

Besides


The mechanism for sessions with section support is to avoid naming conflicts in large projects. An elaborate caching system, with different options for storing values, tags and priorities. Autoloader, which can specify directories that it will scan for classes and interfaces and store this information in the cache.

Instead of conclusion


I must say, the first impression is sometimes deceptive. I sincerely hope that this is not the case.

Framework site - http://nette.org/en/

Source: https://habr.com/ru/post/139479/


All Articles