Nette is not working, white page is displayed

  1. Run Requirements Checker and check, if webhosting supports Nette Framework.
  2. Check if directories temp and log are writable. If you run your web server on SELinux, it is important to change the context type of both temp and log from httpd_sys_content_t to 'httpd_sys_content_rw_t`.
# chcon -R -t httpd_sys_content_rw_t temp log

3. Force Debugger to work in development mode (Debugger::enable(Debugger::DEVELOPMENT)).

Error 404 – page not found

Check the path and the name of template file – lower/upper case, extension .latte.

Use of characters { } in JavaScript

Characters { a } are used for writing Latte macros. By default everything (except space and quotation mark) following the { character is considered a macro. If you need to print character { (often in JavaScript), you can put a space (or other empty character) right after {. By this you avoid interpreting it as a macro.

If it's necessary to print these characters in a situation where they would be interpreted as a macro you can use specials macros to print out these characters – {l} for { and {r} for }

{is macro}
{ is NOT macro }

Routing is not working

  1. It matters if the module is defined in the route by the presenter (i.e. is set the same as presenter) or separately (then the URL must contain <module> to change it)
  2. Check lower/upper case ('Module' => 'Front' will not work, 'module' => 'Front' will).
  3. Check if mod_rewrite is allowed.

Some browsers remember redirection so after a change of router it is necessary to flush their cache.

Randomly appearing open_basedir problem

It is a PHP bug and is solved by upgrading to newer PHP.

Slow Debugger

Set lower depth of nesting arrays and objects Debugger::$maxDepth and smaller length for displaying strings in Debugger::$maxLen.

MIME-type file validation

Sometimes MIME-type validation does not work, respectively throws an error in file which should pass the validation. Problem is not in the Nette Framework. Solve the problem by installing Fileinfo library (in PHP 5.3 it is natively supported and allowed).

I miss a library for AMF, Amazon S3, OpenID, …

Nette Framework does not want to be a library, i.e. a large set of classes providing with numerous services but a framework – a compact set with specific style of work (so called Nette-way). Framework is therefore relatively small but with a series of addons while their most compact set is the Zend Framework.

Template from a string

If you need to use a template (especially Latte) stored in a string (e.g. returned from a database) then set it this way.

How to configure a server for nice URLs?

Apache extension called mod_rewrite must be allowed to create so called cool-URL. These commands will enable and configure mod_rewrite in a .htaccess file.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(pdf|js|ico|gif|jpg|png|css|rar|zip|tar\.gz)$ index.php [L]

To alter Apache configuration with .htaccess files, the AllowOverride directive has to be enabled. This is the default behaviour for Apache.

In nginx, the try_files directive should be used in server configuration:

location / {
    try_files $uri $uri/ /index.php$is_args$args;

Block location must be defined exactly once for each filesystem path in server block. If you already have a location / block in your configuration, add the try_files directive into the existing block.