Troubleshooting

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. See Setting directory permissions.
  3. Force Debugger to work in development mode (Debugger::enable(Debugger::DEVELOPMENT)).

Setting directory permissions

If you're developing on macOS or Linux (or any other Unix based system), you need to configure write privileges to the web server. Assuming your application is located in the default directory /var/www/html (Fedora, CentOS, RHEL)

cd /var/www/html/MY_PROJECT
chmod -R a+rw temp log

On some Linux systems (Fedora, CentOS, …) SELinux may be enabled by default. You may need to update SELinux policies, or set paths of temp and log directories with correct SELinux security context. Directories temp and log should be set to httpd_sys_rw_content_t context; for the rest of the application – mainly app folder – httpd_sys_content_t context will be enough. Run on the server as root:

semanage fcontext -at httpd_sys_rw_content_t '/var/www/html/MY_PROJECT/log(/.*)?'
semanage fcontext -at httpd_sys_rw_content_t '/var/www/html/MY_PROJECT/temp(/.*)?'
restorecon -Rv /var/www/html/MY_PROJECT/

Next, the SELinux boolean httpd_can_network_connect_db needs to be enabled to permit Nette to connect to the database over network. By default, it is disabled. The command setsebool can be used to perform this task, and if the option -P is specified, this setting will be persistent across reboots.

setsebool -P httpd_can_network_connect_db on

Error 500 in production mode

If the application works correctly in development mode and throws a 500 error in production mode, the cause may be in an outdated cache. While Nette cleverly automatically updates the cache in development mode, in production mode it focuses on maximizing performance, and clearing the cache after each code modification is up to you. Try to delete temp/cache.

In any case, the reason for the error is listed in the log. If you don't see anything in the log (and in error 500 is notice Tracy is unable to log error), find out why it can't log errors. For example, switch to development mode and call Tracy\Debugger::log('hello') and Tracy will tell you why it can't log. This may be due to insufficient permissions to write to the log/ directory.

How to configure a server for nice URLs?

Apache: extension mod_rewrite must be allowed and configured 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 behavior for Apache.

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

location / {
	try_files $uri $uri/ /index.php$is_args$args;  # $is_args$args is important
}

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.

Use of characters { } in JavaScript

Characters { a } are used for writing Latte tags. Everything (except space and quotation mark) following the { character is considered a tag. 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 tag.

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

{is tag}
{ is not tag }
{l}is not tag{r}

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

Nette Framework does not want to be a large library that solves everything, 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 Symfony.