Skip to content

Configuration

Jiří Škoda edited this page Apr 21, 2024 · 34 revisions

This page describes contents of CONFIG.YAML file, which can be found at root directory of PHP-Movic. Generally, there is no order of those settings. So, you can rearrange them in your way.

Content
1. General configuration
2. Session configuration
3. Logging configuration
4. Database configuration
5. Routing configuration

General configuration

This part contains configuration which is general for whole application.

DateFormat

Syntax: DateFormat: "<format>"
Parameters:

  • <format>: Format string.

Sets format of date and time used across whole application. For format string options, see date format wiki page.

Timezone

Syntax: Timezone: "<zonename>"
Parameters:

  • <zonename>: Name of time zone.

Sets default time zone for whole application. For supported time zones, see PHP timezones.

PHPErrors

Syntax: PHPErrors: <value>
Parameters:

  • <value>: Boolean value(True or False).

Sets flag, whether PHP errors should be emitted (True) or not (False).

ContentNamespace

Syntax: ContentNamespace: "<namespace>"
Parameters:

  • <namespace>: Name of namespace.

Sets name of namespace, where content can be found. All classes in /CONTENT folder are expected to be in this namespace. For example, if this setting is set to MyApp, then class MyApp\Controller\HomePageController is expected to be in file /CONTENT/CONTROLLER/HOMEPAGECONTROLLER.PHP.
Note: This setting is case insensitive. So class from example (HomePageController) can be also in folder /CONTENT/controller/homepagecontroller.php or /CONTENT/Controller/HomePageController.php.

Counters

Syntax: Counters: "<path>"
Parameters:

  • <path>: Path to file.

Sets path to file, to which application counters will be saved. This file is supposed to be text file. If this file does not exists, new file will be created.

Favicon

Syntax: Favicon: <path>
Parameters:

  • <path>: Path to file.

Sets path to file, which will be sent when there is request for favicon of the application.

Sessions configuration

This part of configuration is dedicated to sessions. All following settings should, in world of rainbows and unicorns, enhance security of whole application.

SessionLifetime

Syntax: SessionLifetime: <interval>
Parameters:

  • <interval>: Integer.

Sets life time of session (in seconds). Counter will be reset after every request sent. When there is interval between requests larger than set lifetime, session will be reset.

SessionIP

Syntax: SessionIP: <flag>
Parameters:

  • <flag>: Boolean (True or False).

Sets flag, whether session is valid for only one IP address (True) or not (False). If set to True and session changes IP address, session is destroyed.

SessionTimeframe

Syntax: SessionTimeframe: <interval>
Parameters:

  • <interval>: Integer (representing seconds).

Sets size of time frame (in seconds), in which requests will be counted.

SessionRequests

Syntax: SessionRequests: <number>
Parameters:

  • <number>: Integer.

Sets maximal number of requests allowed in defined time frame. For example, if there is allowed maximum of 10 requests every 3 seconds, SessionTimeframe should be set to 3 and SessionRequests to 10. Every requests after limit is exceeded will be thrown away.

Logging configuration

Configuration of logging of application. PHP-Movic creates quite good amount of logs. This settings can change behaviour of logs.

LogsAllowed

Syntax: LogsAllowed: <allowed>

  • <allowed>: Boolean (True or False).

Sets flag, whether application should create logs (True) or not (False).

LogLevel

Syntax: LogLevel: <level>
Parameters:

  • <level>: Level of log.

Sets minimal level of log, which will be actually logged. Allowed log values:

  • DEBUG
  • LOW
  • BASE
  • INFO
  • SUCCESS
  • WARNING
  • ERROR
  • CRITICAL

LogDir

Syntax: LogDir: "<path>"
Parameters:

  • <path>: Path to directory.

Sets path to directory, to which all logs will be created.

LogStdout

Syntax: LogStdout: <stdout>
Parameters:

  • <stdout>: Boolean (True for logging to standard output, False for otherwise)

Sets flag, whether logs should be printed also to standard output.

LogFormat

Syntax: LogFormat: "<format>"
Parameters:

  • <format>: Format string

Sets format of each log. Specification of format string can be found at log format wiki page.

LogUseFormat

Syntax: LogUseFormat: <use>
Parameters:

Flag, whether any of format symbols will be used when logging to file.

LogLevelFormat

Syntax:

LogLevelFormat:    
     <level>: "<format>"
     <level>: "<format>"
     <level>: "<format>"
     ...

Parameters:

  • <level>: Any valid level of log
  • <format>: Format of log

Sets format of log for each level of log. As <format>, valid log format is expected. For log level, any of following is valid:

  • DEBUG
  • LOW
  • BASE
  • INFO
  • SUCCESS
  • WARNING
  • ERROR
  • CRITICAL

LogConsole

Syntax: LogConsole: <console>
Parameters:

  • <console>: Boolean (True or False)

Sets flag, whether logging should be done also to web browsers console. If set to True, application will generate <script> tags in which logging to console will be performed. Format of log is same as defined in other cases. This setting is also affected by file log format.

LogSourceLoader

Syntax: LogSourceLoader: <flag>
Parameters:

  • <flag>: Boolean (True or False)

Sets flag, whether source loader of application should also produce logs (True) or not (False). If set to True, source loader will produce logs. Amount of logs produced by source loader could be potentially large and thus reading of logs could be hard. This setting does not affect any warnings or (critical) errors logging of source loader.

Database configuration

This part is dedicated to configuration of database. As this file contains database password in plain text, is really important to hide this file from public distribution.

DatabaseDriver

Syntax: DatabaseDriver: "<name>"
Parameters:

  • <name>: Fully qualified name of driver class.

Sets driver used to connect to the database. The <name> is expected to be fully qualified name of any class, which has source inside /DRIVERS directory.

DatabaseHost

Syntax: DatabaseHost: "<hostname>"
Parameters:

  • <hostname>: Name or IP address.

Sets name or address of machine with running database service. To this machine will application connect for executing database queries.

DatabaseName

Syntax: DatabaseName: "<database>"
Parameters:

  • <database>: Name of database.

Sets name of database on database server which will be used by application and to which application will connect to.

DatabaseUser

Syntax: DatabaseUser: "<user>"
Parameters:

  • <user>: Name of user.

Sets name of user used to connect to the database. When configuring this setting, please keep in mind, that this user needs permission to actually perform queries.

DatabasePassword

Syntax: DatabasePassword: "<password>"
Parameters:

  • <password>: Password in plain text.

Sets password of database user used for connecting to the database.

Routing configuration

This section describes configuration of router.

Routes

Syntax:

Routes:
    "<path>": "<controller>"
    "<path>": "<controller>"
    "<path>": "<controller>"
    ...

Parameters:

  • <path>: Path of request.
  • <controller>: Name of controller class.

Assigns path of request to controller. Path consists only of path to resource(for example: path of URI https://mydomain.com/user/1258/detail?edit=true&encryptionKey=alpha#name is /user/1258/detail). Path matching is not case sensitive, so path /user/detail is the same as /USER/DETAIL. Any of controller is expected to be class in configured namespace, implement interface PHPMovic\Controller\Controller and to be located in directory /CONTENT/CONTROLLER/. Examples of routes:

  • /
  • /home/dirs/
  • /flags/countries/europe/
  • ...

Path syntax

Syntax of the path from routes configuration can be extended by placeholders. Placeholder is part of path which expects any kind of data. Syntax of placeholder is following:
%<NAME>::<TYPE>%
Parameters:

  • <NAME>: Name of placeholder.
  • <TYPE>: Data type of placeholder.

Placeholders are NOT case sensitive, so placeholder /edit/%EDIT::BOOL% will match both /edit/true and /EDIT/TRUE. But there is one exception: values are not converted (it remains same case as in request). If set correctly, router tries to match data type of path and then send value of placeholder (as NAME in request data) to correct controller. Data type of placeholder can be any of following:

  • BOOL for any boolean value (this will match both true and false)
  • INTEGER for any integer number
  • NUMBER for any number (including integer or any decimal number)
  • TEXT for any text (string)

Examples of route with placeholders:

  • /home/%USER::INTEGER%/detail/%TITLE::TEXT%
    • this will match following request path: /home/1989/detail/history; this will set USER to 1989 and TITLE to history
    • this will NOT match following request path: /home/usr/detail/history, because usr cannot be converted to integer
  • /main/customer/%ID::INTEGER/order/%ORDER::STRING%/
    • this will match following request path: /main/customer/1918/order/%order::string%; this will set ID to 1918
    • this will NOT match following request path: /main/customer/1918/order/al18810858dfd; part of path %ORDER::STRING% is not valid placeholder, so to match this path, exact (except case sensitivity) request must be sent.

StaticRoutes

Syntax:

StaticRoutes:
    "<request>": "<path>"
    "<request>": "<path>"
    "<request>": "<path>"
    ...

Parameters:

  • <request>: Path of request.
  • <path>: Path to resource.

Sets paths for static resources, where <request> is part of URL with requested resource, and <path> is path within /CONTENT folder.. This setting does not allow placeholders and is also case insensitive.
Example:

StaticRoutes:
    "/static/css": "/STYLES"

This route will be handled by any request in following format: /static/css/filename.css, where filename.css can be any valid string. This route expects file filename.css to be located at /CONTENT/STYLES/filename.css.

Aliases

Syntax:

Aliases:
    "<origin>": "<destination>"
    "<origin>": "<destination>"
    "<origin>": "<destination>"
    ...

Parameters:

  • <origin>: Path of request.
  • <destination>: Path to which request will be redirected.

Sets aliases for paths. Any request from <origin> will be treated in same way, as request from <destination>. Syntax of both <origin> and <destination> is the same as for normal routes.

Clone this wiki locally