NAME
PEF::Front::Config - how to configure PEF::Front to suit your needs
DESCRIPTION
PEF::Front::Config handles configuration of your apps. The documentation for this module aims to describe how to change settings, and which settings are available.
SETTINGS
Subroutine names in your configuration module *::AppFrontConfig define configuration parameters. This module has to be loaded first on startup. PEF::Front has many sensible defaults but you have to provide some data.
package MyApp::AppFrontConfig;
sub cfg_db_user { "user" }
sub cfg_db_password { "mypassword" }
sub cfg_db_name { "mydb" }
1;
In these subroutines you can return some constants or load them from some source.
You can define your own subroutines and export them to your handlers. PEF::Front::Config has some limited functionality of Exporter.
package MyApp::AppFrontConfig;
our @EXPORT = qw(avatar_images_path);
sub avatar_images_path { cfg_www_static_dir() .'/images/avatars' }
# somewhere in handlers
package MyApp::Local::Avatar;
use PEF::Front::Config;
sub upload {
my ($req, $ctx) = @_;
my $upload_path = avatar_images_path();
# ...
}
It works a little-bit non-trivial: PEF::Front reads parameters from MyApp::AppFrontConfig, determines the whole configuration and re-export it into MyApp::AppFrontConfig. This way you can use automatically calculated configuration data in your configuration subroutines.
PEF::Front::Config::cfg( $config_key
) returns configuration value for the given $config_key
if it doesn't require parameter.
SUPPORTED SETTINGS
- cfg_app_namespace
-
Application modules namespace. By default it's calculated from full name of your *::AppFrontConfig module. But probably you can change it for some unknown reason.
- cfg_cache_file
-
Full path to cache file. Default is
cfg_project_dir() . "/var/cache/shared.cache"
- cfg_cache_method_expire
-
Default expire time for cached responses. By default it's equal to 60 [seconds].
- cfg_cache_module
-
Fully qualified module name or just simple module name inside
PEF::Front::Cache::
that providesPEF::Front::Cache
interface. - cfg_cache_size
-
Cache size. Default is equal to "8m" = 8 Megabytes.
- cfg_captcha_db
-
Sets the directory to hold the database that will be used to store the current non-expired valid captcha tokens. Default is
cfg_project_dir() . "/var/captcha-db"
- cfg_captcha_expire_sec
-
Sets the number of seconds this captcha will remain valid. Default is 300.
- cfg_captcha_font
-
The absolute path to your TrueType (.ttf) font file. Be aware that relative font paths are not recognized due to problems in the libgd library. Default is "giant" - not a good font, you would better change it.
- cfg_captcha_image_class
-
Allows to inject user's captcha image generation class. Default is "PEF::Front::SecureCaptcha" which is really not very pretty but works. Captcha image generation class have to implement only one method:
generate_image( width => $width, height => $height, size => $size, str => $str, code => $sha1, out_folder => $cfg_www_static_captchas_dir, font => cfg_captcha_font(), %$image_init, )
Where $image_init is optional hash reference from cfg_captcha_image_init parameter.
- cfg_captcha_image_init
-
Optional hash reference of extra values for captcha's generate_image method.
- cfg_captcha_secret
-
Salt for secure captcha's code generation. Default is cfg_app_namespace.
- cfg_captcha_symbols
-
Array of symbols for captcha's code.
- cfg_collect_unknown_msgid
-
Boolean value whether to collect or not not translated localized phrases. You can translate these collected phrases later.
-
Cookie-unset sets expiration time of the cookie in the past. This parameter says how much in the past. Default is -3600 seconds - 1 hour.
- cfg_db_name
-
Default full DSN or PostgreSQL's database name. Default is "pef" which is pretty useless. Here "pef" really means "dbi:Pg:dbname=pef".
- cfg_db_password
-
Default password for DB user.
- cfg_db_reconnect_trys
-
How many times it tries to reconnect with 1 second pauses in case some DB connection failure. During this time all queries will be waiting for connection. They will fail after final failure or continue to work as if nothing happened if connection finally comes back.
- cfg_db_user
-
Default DB user name.
- cfg_default_lang
-
Default localization language when guessing from HTTP headers or Geo IP doesn't help.
- cfg_handle_static
-
Boolean value whether your application handle static content or not. Default is false - it is better served by some fast server like Nginx.
- cfg_in_filter_dir
-
Directory of input parameter filter modules. It's better not to change, use it as read-only value. Changing this value you can break framework. Default is "$app_project_dir/InFilter".
- cfg_location_error
-
Redirect for location errors (404). Default is "/appError?msgid=Internal\%20Error".
- cfg_log_level_debug
-
Boolean value whether debug logging is on. Default is false.
- cfg_log_level_error
-
Boolean value whether error logging is on. Default is true.
- cfg_log_level_info
-
Boolean value whether informational logging is on. Default is true.
- cfg_model_dir
-
Directory of model description YAML-files. Default is cfg_project_dir() . "/model".
- cfg_model_local_dir
-
Directory of "local" model handlers modules. Do not change it. Default is "$app_project_dir/Local".
- cfg_model_rules_reload
-
When true, checks wheater file was modified on every input data validation and reloads model description if necessary. Default is false.
- cfg_no_multilang_support
-
Boolean value whether application supports multilanguage. Default is true.
- cfg_no_nls
-
Boolean value whether application localization is off. Default is false. Localization can work without multilanguage support.
- cfg_oauth_connect_timeout
-
Timeout for operations with Oauth2-providers. Default is 15 seconds.
- cfg_out_filter_dir
-
Directory of response output filter modules. It's better not to change, use it as read-only value. Changing this value you can break framework. Default is "$app_project_dir/OutFilter".
- cfg_project_dir
-
Root directory of your application. It is guessed by default from path to your startup file.
- cfg_session_db_file
-
Sets database file that will be used to store the user session data. Default is cfg_project_dir() . "/var/cache/session.db".
- cfg_session_module
-
Fully qualified module name or just simple module name inside
PEF::Front::Session::
that providesPEF::Front::Session
interface. - cfg_session_request_field
-
Sets session identifier field from cookies or form data. Session data can be automatically loaded during request validation. Default is "auth".
- cfg_session_ttl
-
Time to live for session data. Default is 30 days.
- cfg_template_cache
-
Sets directory for compiled templates. Default is cfg_project_dir() . "/var/tt_cache".
- cfg_template_dir_contains_lang
-
Boolean value whether templates for different languages are in their own directories. Default is false.
- cfg_unknown_msgid_db
-
Sets database file for not translated localized messages. You can export these phrases into POT file and translate them later. Default is cfg_project_dir() . "/var/cache/unknown-msgid.db".
- cfg_upload_dir
-
Root directory for uploaded files. Default is cfg_project_dir() . "/var/upload".
- cfg_url_contains_lang
-
Boolean value whether URI path is prefixed with short language name like /en/, /de/, etc. Default is false.
- cfg_url_only_camel_case
-
Boolean value whether routed path can be only in Camel Case form. Default is true.
- cfg_www_static_captchas_dir
-
Directory for generated captcha images. Default is cfg_project_dir() . "/www-static/captchas".
- cfg_www_static_captchas_path
-
URI path for generated captcha images. Default is deducted cfg_www_static_dir from cfg_www_static_captchas_dir.
- cfg_www_static_dir
-
Directory of static content that is usually served directly by web-server.
PARAMETRIZED HOOKS
- cfg_context_post_hook($context)
-
This function is called when request context is already made up but handler is not called yet.
- cfg_logger($request)
-
This method should return subroutine that accept ({level => "warn", message => $message}) and writes log message. By default this function returns
$request->{env}{'psgix.logger'} || sub {$request->{env}{'psgi.errors'}->print($_[0]->{message});}
- cfg_model_rpc($method)
-
This function return subroutine reference that calls "remote" methods for given
$model
. That referenced subroutine recieves($validated_request, $context)
parameters. - cfg_oauth_client_id($service)
-
Returns
client id
of your application for given $service. Default is 'anonymous'. - cfg_oauth_client_secret($service)
-
Returns
client secret
of your application for given $service. Default is 'anonymous_secret'. - cfg_oauth_scopes($service)
-
Returns scopes for given $service. Default is quite sensible for all supported services to obtain user info.
- cfg_parse_extra_params($src, $params, $form)
-
Parses extra parameters from request's path.
By default if
$src
is on of 'app', 'get' then it splits path by '/' and tries to split every part into pair divided by '-'. Left part is parameter name and right part is value. If it was not possible to split by '-' then first parameter is namedcookie
and rest isget_param_$i
with increasing from 1$i
. - cfg_template_dir($request, $lang)
-
Returns one or more directories with templates. Default is cfg_project_dir() . "/templates" or cfg_project_dir() . "/templates/$lang" depending on cfg_template_dir_contains_lang.
AUTHOR
This module was written and is maintained by Anton Petrusevich.
Copyright and License
Copyright (c) 2016 Anton Petrusevich. Some Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.