You are browsing the unmaintained documentation for old Nette 2.0. See documentation for current Nette.

Configuration

Configuration is usually written in NEON format. Have fun trying out the syntax at https://ne-on.org. Many features of Nette Framework can be set up in configuration file. Framework configures itself by a DI container extension (Nette\DI\Extensions\NetteExtension)
which accepts parameters in nette: section of the configuration file.

Sessions

Here you can set all directives (in camelCase format).

nette:
	session:
		autoStart: true  # default is smart
		expiration: 10 days
		name: ...
		...

autoStart: smart starts the session if it already exists and it is a recommended value

Application

nette:
	application:
		debugger: true  # debugger bar panel
		catchExceptions: %productionMode%
		errorPresenter: Front:Error

Routing

nette:
	routing:
		debugger: true  # debugger bar panel
		routes:
				index.php: Dashboard:default
				'<presenter>/<action>[/<id>]': Dashboard:default

Routes are in mask: action format.

Security

nette:
	security:
		debugger: true  # debugger bar panel
		frames: ...  # affects X-Frame-Options header

		users:
			johndoe: secretpassword

		roles:
			guest:
			member:
			admin: [member]  # admin extends member

		resources:
			file:

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.

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: http://allowed-host.com or frames: no.

Mailing

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

nette:
	mailer:
		smtp: true  # use SmtpMailer instead of SendmailMailer
		host: ...
		port: ...
		username: ...
		password: ...
		secure: ...
		timeout: ...

Database

You can define multiple database connections, if you do so you can set which one will be automatically injected to your services by the autowired option. The following code shows how to set up one connection called default.

nette:
	database:
		default:
			dsn: "sqlite2:%appDir%/models/demo.db"
			user: ...
			password: ...
			options: [PDO::MYSQL_ATTR_COMPRESS = true]
			debugger: false  # debugger bar panel
			explain: false  # explain queries in debugger bar
			reflection: discovered  # or conventional or classname, default is discovered
			autowired: true

This creates service @nette.database.default and sets reflection and cache for you.

Forms

You can change default validation error messages.

nette:
	forms:
		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'

Latte

You can turn on and off XHTML rendering mode and register custom macros.

nette:
	latte:
		xhtml: yes  # default is no
	macros:
		- App\MyLatteMacros::register  # static method, classname or callable

DI container

nette:
	container:
		debugger: true  #debugger bar panel

Debugger

nette:
	debugger:
		email: webmaster@example.com  # for sending error logs
		strictMode: TRUE
		editor: ...
		browser: ...

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

		blueScreen:  # blue screen panels
			- DoctrinePanel::renderException

Low-level modifications

All these settings affect final DI container. Compared to direct definition in services section it provides shorter and more straightaway syntax. If you need to tune these services by yourself, you can redefine them:

services:
	nette.mailer:
		class: MySmtpMailer

	nette.presenterFactory:
		class: MyPresenterFactory

Or create new services extending the default ones:

services:
	myConnection < nette.database.default:
		setup:
			$onQuery: [ @logger::log ]

Services definitions

See services.

services:
	database:
		class: Nette\Database\Connection(%dsn%, %user%, %password%)

#or in two lines
		class: Nette\Database\Connection
		arguments: [%dsn%, %user%, %password%]

Improve this page