Installation
composer create-project "genesis-dev/landing-form":"v0.1.1-beta" landing-form, (*1)
Configuring
/config/local.php - overwrites /config/main.php (using array_merge_recursive), (*2)
<?php
return [
"db" => [ // Database settings
'database_type' => '',
'database_name' => '',
'server' => '',
'username' => '',
'password' => '',
'charset' => 'utf8',
],
"telegram" => [ // Telegram settings
"api_key" => "",
],
"defaults" => [
"mailer" => [ // SMTP settings
"host" => '',
"username" => '',
"password" => '',
"from" => '',
"fromName" => "",
"subject" => "",
"to" => ["mail@example.com", "mail2@example.com"],
],
"telegram" => [
"channel_name" => "", // Telegram channel name (without @)
"include" => ["email", "phone"], // Names of fields to include in messages
],
],
"sites" => [
"siteID" => [ // Array, similar structure to defaults and overwrites them. Key is siteID.
],
"test_null" => [ // Configurations for tests
"mailer" => false,
],
"test_mail" => [
],
"test_telegram" => [
"mailer" => false,
"telegram" => [
"channel_name" => "genesis_orders",
],
],
"test_all" => [
"telegram" => [
"channel_name" => "genesis_orders",
],
],
],
];
/config/main.php, (*3)
<?php
$config = [
"defaults" => [
"validators" => [
"email" => function($str, $fields, $validators) { // $str - field value, $fields - other fields, $validators - other validators
return !empty($str) && filter_var($str, FILTER_VALIDATE_EMAIL);
},
"phone" => function($str, $fields, $validators) {
return !empty($str) && preg_match('/^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$/', $str);
},
],
],
"table" => "landing_form", // Table name in DB
];
//......
Usage