eesyphp/docs/config.md
Benjamin Renard 6fdc5447f1 Some improvments from recent works on apps based on its "framework"
* Code cleaning and fix some small errors using Phpstan
* Configure pre-commit to run Phpstan before each commit
* Some little improvments and logging, mail, smarty & URL libs
* Add Sentry integration
* Add Webstat JS code inclusion
* Install Smarty dependency using composer

Breaking changes:
* Rename Event class as HookEvent to avoid conflict with PECL event
* URL with refresh GET parameter now automatically trigger redirection without it
 after page loading to avoid to keep it in URL
2023-01-29 11:51:41 +01:00

4.8 KiB

Configuration

The main configuration file is includes/config.inc.php. You can overrides all variables that main configuration file contain in your own configuration file includes/config.local.php. This file will be automatically included if present.

Note : In the configuration files, to refer to the application root directory, you could use the variable $root_dir_path (that does not contain the trailing slash).

The first thing you have to configured is the public root URL of the API in $public_root_url variable. This URL could be relative (default) or absolute.

Note : You also could adapt $main_pagetitle and $included_css_files to your situation.

Data/files directories :

All application data are, by default, in data sub-directory. You could configure it by using the following variables :

  • $data_dir : Root DATA directory (Default : data)
  • $tmp_root_dir : Root temporary files directory (Default : $data_dir/tmp)
  • $logs_dir_path : Logs directory (Default : $data_dir/logs)
  • $upload_tmp_dir : Temporary directory for PHP uploading files : when uploading files, PHP will stored files in this directory before application move it to their final destination (Default : $data_dir/uploading)
  • $smarty_templates_c_dir : Templates cache directory (Default : $tmp_root_dir/templates_c)

Logs :

Default log files path is data/logs/app.log (and data/logs/cli.log for CLI tool). This could be configured using $log_file configuration variable. You can also set the log level using $log_level variable (default value = "INFO", see config.inc.php).

Database configuration :

The database is used to store demo items information. For this reason, a basic Sqlite database could be used and is the default database backend. However, you can use any database backend supported by the PHP PDO abstraction system.

The database connection is configured using the following variables :

  • $dn_dsn : the Data Source Name (DSN) depending on your database backend.
  • $db_user : the database username.
  • $db_pwd : the database password.
  • $db_options : the database connection options (see your PHP PDO Driver documentation). By default, this variable value is an empty array ("array()").
  • $db_date_format : the date format as retreive from the database.
  • $db_datetime_format : the date and time format as retreive from the database.

Note : You could find some configuration examples for PostgreSQL, MariaDB / MySQL or Sqlite in config.inc.php file. Initial SQL files could also be found in data directory.

E-mail configuration :

This application send some mail by using PEAR Mail library. The path of this library must be specify using $php_mail_path. The default value corresponding to the version provided by php-mail Debian package.

This library support different methods to send mail and the default one is SMTP. This method require that the PEAR Net_SMTP library is also installed on the system. You could configure another method sending method using the variable $mail_send_method (see comment in config.inc.php file or the PEAR Mail library documentation).

Depending on the sending method choose, some options are available to configure their usage (see comment in config.inc.php file or the PEAR Mail library documentation) and could be configured using $mail_send_params variable.

To forge e-mail, this application use PEAR Mail_Mime library. The path of this library must be specify using $php_mail_mime_path. The default value corresponding to the version provided by php-mail-mime Debian package.

Some other variables exist to manage the email sending by the application :

  • $mail_headers : an PHP array of default headers add to mail sent by the application
  • $mail_sender : the email address of the sender of all emails sent by the application
  • $mail_catch_all : for debugging purpose, you can using this variable to specify an email address that will received all email sent by the application in place of the original recipient

Web stats JS code inclusion

If you use a Web stats tool that need to include a piece of JS code in all page like Matomo, you could defined the $webstats_js_code variable.

Sentry integration

If you want to enable the Sentry integration, you have to define the $sentry_dsn. This integration permit to report PHP errors (see $sentry_php_error_types) and exception as issues and to monitor performance of the application (see $sentry_traces_sample_rate).