Framework Configuration

An overview of all configuration options in Nette Framework.

Nette application is easily configured using configuration files. They are usually written in NEON format. Have fun trying out the syntax.

Access Control

By filling in users option you create SimpleAuthenticator, by defining roles or resources you create Nette\Security\Permission authorizator. More in User Authorization and Privileges.

    debugger: true  # debugger bar panel

        johndoe: secretpassword

        admin: [member]  # admin extends member




The errorPresenter specifies the presenter which is invoked when an error occurs. We can find an example in the sandbox. Parameter catchExceptions decides if the error presenter will be invoked. By changing this value to true in the debug mode we can test functionality of the error presenter.

    debugger: true # shows panel in Tracy bar
    errorPresenter:  ...  # default: Nette:Error
    catchExceptions: ...  # default: enabled in production mode
    silentLinks: ...      # default: false

Option silentLinks specifies Nette behaviour in the debug mode when a link generation fails. With false value Nette will trigger E_USER_WARNING. Changing this configuration option to true will suppress this error. In production environment, E_USER_WARNING will be always triggered. We can also adjust this behaviour using class property Presenter::$invalidLinkMode.


Default value: *: *Module\*Presenter (in the sandbox *: App\*Module\Presenters\*Presenter)

This parameter contains an array with rules for converting presenter name to the class name. In the key we define a module name or * as a fallback for other modules. The value contains the rule mask:

        Admin: App\Admin\*Module\*Presenter
        *: App\*Module\Presenters\*Presenter

The presenter Front:Blog:Article is contained inside the Front module. Since this module has no explicit mapping, the mapping with asterisk will be used and the class will be called App\FrontModule\BlogModule\Presenters\ArticlePresenter. The presenter Admin:User:Edit is part of the Admin module which has separate mapping so the name of the presenter class will be App\Admin\UserModule\EditPresenter (note that since the Admin is already in the mapping definition, it will be stripped from the resulting class name).

Automatic registration of presenters

Nette automatically registers presenters as services. This step improves presenter creation speed. There are few configuration options that adjust where and how Nette looks for them.

The scanComposer specifies if Nette should look for presenters in the Composer classmap. The scanFilter specifies the string which must be included in the file and class name.

Value scanDir contains an array with directories where Nette looks for the presenters. If we specify another value in the configuration, it will be merged with the default one %appDir%:

    scanComposer: no  # default: true
    scanFilter: Page  # default: Presenter
        - foo

In this case scanDirs will contain values %appDir% and foo. If we want to disable or overwrite this configuration option, we need to use ! modifier:

        - foo

Now scanDirs will contain only foo.


Mandatory item is only dsn:

        dsn: "sqlite2:%appDir%/models/demo.db"

The Framework creates not only the Nette\Database\Connection object, but also sets the auxiliary objects as a reflection & cache and adds a panel to the Tracy bar in the developer mode.

Other settings are as follows:

    dsn: 'mysql:host=;dbname=test'
    user: root
    password: password
        lazy: true  # establish a connection when it is needed for the first time
        driverClass:  .... # class database driver
    debugger: true         # show panel in Tracy baru
    explain:  true         # show query explains in Tracy bar
    autowired: true # enabled for first defined connection
    conventions: discovered # or 'static' or class name, the default is 'discovered'

In the options option, you can specify additional values ​​found in the PDO drivers documentation.

In the configuration file, we can define more than one database connection:

        dsn: 'mysql:host=;dbname=test'
        user: root
        password: password

        dsn: 'sqlite::memory:'

Each connection defined in this way creates two services – the Nette\Database\Connection object named as database.[NAME].connection (in our case, database.main.connection and database.anotherDb.connection) and the Nette\Database\Context object named as database.[NAME].context that is used when working with the Database Explorer layer.

First connection services are passed through autowiring, however we can turn it off by autowired: no, and turn on for another connection via autowired: yes.

Other non-autowired connections can be passed explicitly in the configuration:

    - UserManager(@database.anotherDb.connection) # or @database.anotherDb.context

DI Container

    debugger: false  # disables DI panel


You can change default validation error messages.

        EQUAL: 'Please enter %s.'
        FILLED: 'Please complete mandatory field.'
        MIN_LENGTH: 'Please enter a value of at least %d characters.'
        EMAIL: '%label must be valid e-mail'

HTTP Headers

    frames: ...               # header X-Frame-Options

    X-Powered-By: MyCMS       # custom HTTP header

csp:                          # Content Security Policy
    script-src: [
        nonce                 # for browsers that support CSP2
        self, unsafe-inline   # for browsers that support CSP1

For security reasons Nette Framework sends HTTP header X-Frame-Options: SAMEORIGIN by default, so that the page can be embedded in iframe only from pages on the same domain. This behavior may be unwanted in certain situations (for example if you are developing a facebook application). You can override this setting by frames: yes, frames: or frames: no.

HTTP Proxies

You can define your HTTP proxy, so that HTTP request's remote address and remote host will be correct.

    proxy:  # IP address, range, hostname or array of these values


You can turn on and off XHTML rendering mode and register custom macros. Custom macros may be passed either as a class name or as a service reference. The default called method is install, you may change it by appending a double colon and a custom method name.

    xhtml: yes  # default is no
        - App\MyLatteMacros::register  # static method, classname or callable
        - @App\MyLatteMacrosFactory    # service with install method
        - @App\MyLatteMacrosFactory::register # service with register method

    - App\MyLatteMacrosFactory


Default mailer is SendmailMailer. By setting smtp you activate SmtpMailer.

    smtp: true  # use SmtpMailer instead of SendmailMailer
    # optional settings
    host: ...
    port: ...
    username: ...
    password: ...
    secure: # possible values are ssl, tls or null
    timeout: ...


By default session will expire in a moment when a browser window is closed. Change the expiration time as follows:

    expiration: 14 days

Automatic session start:

    autoStart: true # výchozí hodnota je 'smart'

Default autoStart: smart is recommended. It automatically starts the session only if it already exists.

If you're using a shared hosting, it's suitable to use a custom directory for storing files with session relations:

    savePath: "%tempDir%/sessions"

In this case, %tempDir% will be replaced by value you set in $configurator->setTempDirectory() in bootstrap.php.

If you want to extend the validity of a session (or authentication) for subdomains, let's set just another cookie parameters:

    cookieDomain: ''

You can set all PHP directives (in camelCase format).

Tracy Debugger

    email:  # for sending error logs
    strictMode: true
    editor: ...
    browser: ...

    bar:  # debugger bar panels
        - Nette\Bridges\DITracy\ContainerPanel  # alias of DI container bar
        - IncludePanel
        - XDebugHelper('myIdeKey')
        - MyPanel(@MyService)

    blueScreen:  # blue screen panels
        - DoctrinePanel::renderException

Low-level Modifications

All these settings affect the contents of the DI container and the system services it creates. All these services can still be changed to a low-level. For instance, we can change class of service application.application, which is by default Nette\Application\Application:

        factory: MyApplication
        alteration: yes

The `alteration 'flag is informative and says we only modify an existing service.

We can also add setup:

        factory: MyApplication
        alteration: yes
            - $onStartup = [@resource::init]


The configuration file is place where we add definitions of our own services in section services. See the DI: Services Configuration chapter for a detailed description.

For example, this is definition of service named database which is PDO instance:

    database: PDO('mysql:host=;dbname=test', root, password)