Overview of configuration options for the Nette Application.
application: # shows "Nette Application" panel in Tracy BlueScreen? debugger: ... # (bool) defaults to true # will error-presenter be called on error? catchExceptions: ... # (bool) defaults to true in production mode # name of error-presenter errorPresenter: Error # (string) defaults to 'Nette:Error' # do bad links generate warnings? # has effect only in developer mode silentLinks: ... # (bool) defaults to false
Because error-presenters are not called by default in development mode and the errors are displayed by Tracy, changing the
true helps to verify that error-presenters works correct during
silentLinks determines how Nette behaves in developer mode when link generation fails (for example, because
there is no presenter, etc). The default value
false means that Nette triggers
true suppresses this error message. In a production environment,
E_USER_WARNING is always invoked. We
can also influence this behavior by setting the presenter variable $invalidLinkMode.
Defines the rules according to which the name of the class (for example
derived from the name of the presenter (for example
Homepage). This the mapping can be achieved with the following
application: mapping: *: App\Presenters\*Presenter
The presenter name is replaced with an asterisk and the result is the class name. Easy!
If we divide presenters into modules, we can have our own mapping for each module:
application: mapping: Front: App\Modules\Front\*Presenter Admin: App\Modules\Admin\*Presenter Api: App\Api\*Presenter
Front:Homepage maps to class
`App\Modules\Front\HomepagePresenter and presenter
Admin:Dashboard to class
It will be more handy to create a general (asterisk) rule that will replace the first two rules and add an extra asterisk just for the module:
application: mapping: *: App\Modules\*\*Presenter Api: App\Api\*Presenter
Again, the presenter
Front:Homepage maps to the class
But what if we use nested modules and have a presenter
Admin:User:Edit? In this case, the segment with an asterisk
representing the module for each level is simply repeated and the result is class
An alternative notation is to use an array consisting of three segments instead of a string:
application: mapping: *: [App\Modules, *, *Presenter]
This entry is equivalent to the original
The default value is
Automatic Registration of Presenters
Nette automatically adds presenters as services to the DI container, which significantly speeds up their creation. How Nette finds out presenters can be configured:
application: # to look for presenters in Composer class map? scanComposer: ... # (bool) defaults to true # a mask that must match the class and file name scanFilter: ... # (string) defaults to '*Presenter' # in which directories to look for presenters? scanDirs: # (string|false) defaults to '%appDir%' - %vendorDir%/mymodule
The directories listed in
scanDirs do not override the default value
%appDir%, but complement it, so
scanDirs will contain both paths
%vendorDir%/mymodule. If we want to overwrite
the default directory, we use exclamation mark:
application: scanDirs!: - %vendorDir%/mymodule
Directory scanning can be turned off by setting false. We do not recommend completely suppressing the automatic addition of presenters, otherwise application performance will be reduced.
This setting globally affects the behavior of Latte in components and presenters.
latte: # shows Latte panel in the Tracy Bar for the main template (true) or for all components (all)? debugger: ... # (true|false|'all') defaults to true # switches Latte to XHTML mode (deprecated) xhtml: ... # (bool) defaults to false # generates templates with declare(strict_types=1) strictTypes: ... # (bool) defaults to false # class of $this->template templateClass: App\MyTemplateClass # defaults to Nette\Bridges\ApplicationLatte\DefaultTemplate
It is also possible to register new tags either by entering the class name or by referring to the service. Method
install() is called by default, but this can be changed by specifying the name of another method:
latte: # registration of user Latte tags macros: - App\MyLatteMacros::register # static method, classname or callable - @App\MyLatteMacrosFactory # service with install method - @App\MyLatteMacrosFactory::register # service with register method services: - App\MyLatteMacrosFactory
routing: # shows routing panel in Tracy Bar? debugger: ... # (bool) defaults to true # to serialize router to DI container? cache: ... # (bool) defaults to false
Router is usually defined in the RouterFactory class, a more limited alternative can be defined in the configuration using
routing: routes: 'detail/<id>': Admin:Home:default '<presenter>/<action>': Front:Home:default
Creating PHP constants.
constants: FOOBAR: 'baz'
FOOBAR constant will created after startup.
You can set PHP directives. An overview of all directives can be found at php.net.
php: date.timezone: Europe/Prague