General tools
You get several simple features, which can be used anywhere in the program.
Env
Env
static class is a container for environment variables. Some of variables are preset by router. You can use Env
to set more according to your needs.
Variables are stored in an array, but the access methods use convenient object-like notation:
You can also concatenate strings and push an element to the end of an array:
Env
is initiated in Bootstrap, where you should declare an app mode:
When you aren't in production mode and you use Tracy, all your Env
variables are visible in the bottom-right Tracy bar.
Tracy
Enable Tracy to use awesome debugging features of Nette Framework.
You can use Nette Dumper in any place to see your data for debugging:
You can also configure your Tracy bar, see Tracy guide.
Log
Log
static class provides simple logging features, like always PSR-3 compatible. So you can log with levels: emergency
, alert
, critical
, error
, warning
, notice
, info
, debug
. Provide a text message and optionally a context, which is any data structure.
Log
gives you one more level view
to register messages, which are relevant to the user. View messages are stored in an array Log::$viewMessages
You can measure a performance of certain fragments of your code, defining jobs. Find results in the log file.
Log
must be set before the first use, to inject a logger. It is done usually at the beginning of routes.php
:
You must pass to the new logger a log file name. Set a file size in Mb, on which log files will be shifted.
If you want to log any part of your app in a separate log file, use Logger
independently. At the 3-rd argument you can set max number of archived files.
To reduce the amount of logged messages, specify a minimum level to be logged:
Last updated