-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration
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. Logging configuration |
| 3. Database configuration |
| 4. Routing configuration |
This part contains configuration which is general for whole application.
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.
Syntax: Timezone: "<zonename>"
Parameters:
-
<zonename>: Name of time zone.
Sets default time zone for whole application. For supported time zones, see PHP timezones.
Syntax: PHPErrors: <value>
Parameters:
-
<value>: Boolean value(TrueorFalse).
Sets flag, whether PHP errors should be emitted (True) or not (False).
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.
Configuration of logging of application. PHP-Movic creates quite good amount of logs. This settings can change behaviour of logs.
Syntax: LogsAllowed: <allowed>
-
<allowed>: Boolean (TrueorFalse).
Sets flag, whether application should create logs (True) or not (False).
Syntax: LogLevel: <level>
Parameters:
-
<level>: Level of log.
Sets minimal level of log, which will be actually logged. Allowed log values:
LOWBASEINFOSUCCESSWARNINGERRORCRITICAL
Syntax: LogDir: "<path>"
Parameters:
-
<path>: Path to directory.
Sets path to directory, to which all logs will be created.
Syntax: LogStdout: <stdout>
Parameters:
-
<stdout>: Boolean (Truefor logging to standard output,Falsefor otherwise)
Sets flag, whether logs should be printed also to standard output.
Syntax: LogFormat: "<format>"
Parameters:
-
<format>: Format string
Sets format of each log. Specification of format string can be found at log format wiki page.
Syntax: LogUseFormat: <use>
Parameters:
-
<use>: Boolean(Truefor using whole log format with format symbols when logging to file,Falsefor otherwise)
Flag, whether any of format symbols will be used when logging to file.
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:
LOWBASEINFOSUCCESSWARNINGERRORCRITICAL
Syntax: LogConsole: <console>
Parameters:
-
<console>: Boolean (TrueorFalse)
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.
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.
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.
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.
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.
Syntax: DatabasePassword: "<password>"
Parameters:
-
<password>: Password in plain text.
Sets password of database user used for connecting to the database.
This section describes configuration of router.
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/- ...
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:
-
BOOLfor any boolean value (this will match bothtrueandfalse) -
INTEGERfor any integer number -
NUMBERfor any number (including integer or any decimal number) -
TEXTfor 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 setUSERto1989andTITLEtohistory - this will NOT match following request path:
/home/usr/detail/history, becauseusrcannot be converted to integer
- this will match following request path:
-
/main/customer/%ID::INTEGER/order/%ORDER::STRING%/- this will match following request path:
/main/customer/1918/order/%order::string%; this will setIDto 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
- this will match following request path: