Skip to content

Commit

Permalink
Adding .env support (slawkens#1)
Browse files Browse the repository at this point in the history
* - adding composer

* - adding .env support
  • Loading branch information
danilopucci authored Dec 21, 2023
1 parent 08d67a0 commit 79c570c
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 10 deletions.
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
WEBSITE_DATABASE_USER=my_user
WEBSITE_DATABASE_PASSWORD=my_password
WEBSITE_DATABASE_NAME=my_database_name
WEBSITE_DATABASE_HOST_IP=my_database_ip
WEBSITE_DATABASE_HOST_PORT=my_database_port
WEBSITE_URL=https://myurl.com
WEBSITE_EMAIL_SMTP=smtp.myhost.com
WEBSITE_EMAIL_SMTP_PORT=587
WEBSITE_EMAIL=noreply@myname.com
WEBSITE_EMAIL_PASSWORD=myemailpassword
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,5 @@ landing

# others/rest
system/pages/downloads.php

.env
6 changes: 6 additions & 0 deletions .htaccess.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php [L]
</IfModule>

# block files which needs to be hidden, specify .example extension of the file
<Files ~ "\.(env|json|config.js|md|gitignore|gitattributes|lock)$">
Order allow,deny
Deny from all
</Files>
27 changes: 27 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"require": {
"php": "^8.0",
"ext-pdo": "*",
"ext-pdo_mysql": "*",
"ext-json": "*",
"ext-xml": "*",
"ext-dom": "*",
"phpmailer/phpmailer": "^6.1",
"composer/semver": "^3.2",
"twig/twig": "^2.0",
"erusev/parsedown": "^1.7",
"nikic/fast-route": "^1.3",
"matomo/device-detector": "^6.0",
"illuminate/database": "^10.18",
"peppeocchi/php-cron-scheduler": "4.*",
"vlucas/phpdotenv": "^5.5"
},
"require-dev": {
"filp/whoops": "^2.15"
},
"autoload": {
"psr-4": {
"MyAAC\\": "system/src"
}
}
}
24 changes: 14 additions & 10 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
* @link https://my-aac.org
*/

require_once __DIR__ . '/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();

$config = array(
// directories & files
'server_path' => '', // path to the server directory (same directory where config file is located)
Expand Down Expand Up @@ -69,11 +73,11 @@
'cache_prefix' => 'myaac_', // have to be unique if running more MyAAC instances on the same server (except file system cache)

// database details (leave blank for auto detect from config.lua)
'database_host' => '',
'database_port' => '', // leave blank to default 3306
'database_user' => '',
'database_password' => '',
'database_name' => '',
'database_host' => $_ENV['WEBSITE_DATABASE_HOST_IP'],
'database_port' => $_ENV['WEBSITE_DATABASE_HOST_PORT'], // leave blank to default 3306
'database_user' => $_ENV['WEBSITE_DATABASE_USER'],
'database_password' => $_ENV['WEBSITE_DATABASE_PASSWORD'],
'database_name' => $_ENV['WEBSITE_DATABASE_NAME'],
'database_log' => false, // should database queries be logged and and saved into system/logs/database.log?
'database_socket' => '', // set if you want to connect to database through socket (example: /var/run/mysqld/mysqld.sock)
'database_persistent' => false, // use database permanent connection (like server), may speed up your site
Expand Down Expand Up @@ -123,12 +127,12 @@
'html' => ''/*'<br/>My Server,\n<a href="http://www.myserver.com">myserver.com</a>'*/
),
'smtp_enabled' => false, // send by smtp or mail function (set false if use mail function, set to true if you use GMail or Microsoft Outlook)
'smtp_host' => '', // mail host. smtp.gmail.com for GMail / smtp-mail.outlook.com for Microsoft Outlook
'smtp_port' => 25, // 25 (default) / 465 (ssl, GMail) / 587 (tls, Microsoft Outlook)
'smtp_host' => $_ENV['WEBSITE_EMAIL_SMTP'], // mail host. smtp.gmail.com for GMail / smtp-mail.outlook.com for Microsoft Outlook
'smtp_port' => $_ENV['WEBSITE_EMAIL_SMTP_PORT'], // 25 (default) / 465 (ssl, GMail) / 587 (tls, Microsoft Outlook)
'smtp_auth' => true, // need authorization?
'smtp_user' => 'admin@example.org', // here your email username
'smtp_pass' => '',
'smtp_secure' => '', // What kind of encryption to use on the SMTP connection. Options: '', 'ssl' (GMail) or 'tls' (Microsoft Outlook)
'smtp_user' => $_ENV['WEBSITE_EMAIL'], // here your email username
'smtp_pass' => $_ENV['WEBSITE_EMAIL_PASSWORD'],
'smtp_secure' => 'ssl', // What kind of encryption to use on the SMTP connection. Options: '', 'ssl' (GMail) or 'tls' (Microsoft Outlook)
'smtp_debug' => false, // set true to debug (you will see more info in error.log)

// reCAPTCHA (prevent spam bots)
Expand Down

0 comments on commit 79c570c

Please sign in to comment.