mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 22:03:49 -07:00
Merge pull request #602 from torrentpier/revert-599-remove-env
Revert "Removed ENV"
This commit is contained in:
commit
7dddf096fd
5 changed files with 138 additions and 7 deletions
12
.env.example
Normal file
12
.env.example
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# Common params
|
||||||
|
APP_NAME=TorrentPier
|
||||||
|
APP_ENV=local
|
||||||
|
APP_DEBUG=false
|
||||||
|
|
||||||
|
# Database credentials
|
||||||
|
DB_CONNECTION=mysql
|
||||||
|
DB_HOST=localhost
|
||||||
|
DB_PORT=3306
|
||||||
|
DB_DATABASE=torrentpier
|
||||||
|
DB_USERNAME=root
|
||||||
|
DB_PASSWORD=secret
|
44
common.php
44
common.php
|
@ -50,10 +50,50 @@ if (!file_exists(__DIR__ . '/vendor/autoload.php')) {
|
||||||
}
|
}
|
||||||
require_once __DIR__ . '/vendor/autoload.php';
|
require_once __DIR__ . '/vendor/autoload.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of an environment variable. Supports boolean, empty and null.
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @param mixed $default
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function env($key, $default = null)
|
||||||
|
{
|
||||||
|
$value = getenv($key);
|
||||||
|
if (!$value) return value($default);
|
||||||
|
switch (strtolower($value)) {
|
||||||
|
case 'true':
|
||||||
|
case '(true)':
|
||||||
|
return true;
|
||||||
|
case 'false':
|
||||||
|
case '(false)':
|
||||||
|
return false;
|
||||||
|
case '(null)':
|
||||||
|
return null;
|
||||||
|
case '(empty)':
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the default value of the given value.
|
||||||
|
*
|
||||||
|
* @param mixed $value
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function value($value)
|
||||||
|
{
|
||||||
|
return $value instanceof Closure ? $value() : $value;
|
||||||
|
}
|
||||||
|
|
||||||
// Get initial config
|
// Get initial config
|
||||||
|
if (!getenv('APP_DEBUG') && file_exists(__DIR__ . '/.env')) {
|
||||||
|
(new Symfony\Component\Dotenv\Dotenv())->load(__DIR__ . '/.env');
|
||||||
|
}
|
||||||
require_once __DIR__ . '/library/config.php';
|
require_once __DIR__ . '/library/config.php';
|
||||||
|
|
||||||
// Get local config
|
// Local config
|
||||||
if (file_exists(__DIR__ . '/library/config.local.php')) {
|
if (file_exists(__DIR__ . '/library/config.local.php')) {
|
||||||
require_once __DIR__ . '/library/config.local.php';
|
require_once __DIR__ . '/library/config.local.php';
|
||||||
}
|
}
|
||||||
|
@ -96,9 +136,11 @@ define('BOT_UID', -746);
|
||||||
* Progressive error reporting
|
* Progressive error reporting
|
||||||
*/
|
*/
|
||||||
if ($bb_cfg['bugsnag']['enabled']) {
|
if ($bb_cfg['bugsnag']['enabled']) {
|
||||||
|
if (env('APP_ENV', 'production') !== 'local') {
|
||||||
/** @var Bugsnag\Handler $bugsnag */
|
/** @var Bugsnag\Handler $bugsnag */
|
||||||
$bugsnag = Bugsnag\Client::make($bb_cfg['bugsnag']['api_key']);
|
$bugsnag = Bugsnag\Client::make($bb_cfg['bugsnag']['api_key']);
|
||||||
Bugsnag\Handler::register($bugsnag);
|
Bugsnag\Handler::register($bugsnag);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (DBG_USER) {
|
if (DBG_USER) {
|
||||||
/** @var Whoops\Run $whoops */
|
/** @var Whoops\Run $whoops */
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
"rych/bencode": "v1.0.0",
|
"rych/bencode": "v1.0.0",
|
||||||
"samdark/sitemap": "2.4.0",
|
"samdark/sitemap": "2.4.0",
|
||||||
"swiftmailer/swiftmailer": "v6.3.0",
|
"swiftmailer/swiftmailer": "v6.3.0",
|
||||||
|
"symfony/dotenv": "4.*",
|
||||||
"symfony/polyfill": "v1.27.0"
|
"symfony/polyfill": "v1.27.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
|
73
composer.lock
generated
73
composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "2ac8346651466f89508650fddb2461db",
|
"content-hash": "530818326ea7baa3a459b76781f0157a",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "bugsnag/bugsnag",
|
"name": "bugsnag/bugsnag",
|
||||||
|
@ -1173,6 +1173,75 @@
|
||||||
"abandoned": "symfony/mailer",
|
"abandoned": "symfony/mailer",
|
||||||
"time": "2021-10-18T15:26:12+00:00"
|
"time": "2021-10-18T15:26:12+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/dotenv",
|
||||||
|
"version": "v4.4.37",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/dotenv.git",
|
||||||
|
"reference": "fcedd6d382b3afc3e1e786aa4e4fc4cf06f564cf"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/dotenv/zipball/fcedd6d382b3afc3e1e786aa4e4fc4cf06f564cf",
|
||||||
|
"reference": "fcedd6d382b3afc3e1e786aa4e4fc4cf06f564cf",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.1.3"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"symfony/process": "^3.4.2|^4.0|^5.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Component\\Dotenv\\": ""
|
||||||
|
},
|
||||||
|
"exclude-from-classmap": [
|
||||||
|
"/Tests/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Fabien Potencier",
|
||||||
|
"email": "fabien@symfony.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Registers environment variables from a .env file",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"dotenv",
|
||||||
|
"env",
|
||||||
|
"environment"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/dotenv/tree/v4.4.37"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2022-01-02T09:41:36+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/polyfill",
|
"name": "symfony/polyfill",
|
||||||
"version": "v1.27.0",
|
"version": "v1.27.0",
|
||||||
|
@ -1391,5 +1460,5 @@
|
||||||
"php": "^7.1.3"
|
"php": "^7.1.3"
|
||||||
},
|
},
|
||||||
"platform-dev": [],
|
"platform-dev": [],
|
||||||
"plugin-api-version": "2.2.0"
|
"plugin-api-version": "2.3.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,14 @@ $bb_cfg['tp_release_codename'] = 'Bison';
|
||||||
// Настройка баз данных ['db']['srv_name'] => (array) srv_cfg;
|
// Настройка баз данных ['db']['srv_name'] => (array) srv_cfg;
|
||||||
// порядок параметров srv_cfg (хост, название базы, пользователь, пароль, charset, pconnect);
|
// порядок параметров srv_cfg (хост, название базы, пользователь, пароль, charset, pconnect);
|
||||||
$bb_cfg['db'] = [
|
$bb_cfg['db'] = [
|
||||||
'db' => ['localhost', 'torrentpier', 'root', 'root', 'utf8', false],
|
'db' => [
|
||||||
|
env('DB_HOST', 'localhost'),
|
||||||
|
env('DB_DATABASE', 'torrentpier'),
|
||||||
|
env('DB_USERNAME', 'root'),
|
||||||
|
env('DB_PASSWORD', 'pass'),
|
||||||
|
'utf8',
|
||||||
|
false
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$bb_cfg['db_alias'] = [
|
$bb_cfg['db_alias'] = [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue