Removed ENV

This commit is contained in:
Roman Kelesidis 2023-03-16 14:23:32 +07:00
commit 25bc51eebb
5 changed files with 7 additions and 138 deletions

View file

@ -1,12 +0,0 @@
# 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

View file

@ -50,50 +50,10 @@ if (!file_exists(__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
if (!getenv('APP_DEBUG') && file_exists(__DIR__ . '/.env')) {
(new Symfony\Component\Dotenv\Dotenv())->load(__DIR__ . '/.env');
}
require_once __DIR__ . '/library/config.php';
// Local config
// Get local config
if (file_exists(__DIR__ . '/library/config.local.php')) {
require_once __DIR__ . '/library/config.local.php';
}
@ -136,11 +96,9 @@ define('BOT_UID', -746);
* Progressive error reporting
*/
if ($bb_cfg['bugsnag']['enabled']) {
if (env('APP_ENV', 'production') !== 'local') {
/** @var Bugsnag\Handler $bugsnag */
$bugsnag = Bugsnag\Client::make($bb_cfg['bugsnag']['api_key']);
Bugsnag\Handler::register($bugsnag);
}
/** @var Bugsnag\Handler $bugsnag */
$bugsnag = Bugsnag\Client::make($bb_cfg['bugsnag']['api_key']);
Bugsnag\Handler::register($bugsnag);
} else {
if (DBG_USER) {
/** @var Whoops\Run $whoops */

View file

@ -53,7 +53,6 @@
"rych/bencode": "v1.0.0",
"samdark/sitemap": "2.4.0",
"swiftmailer/swiftmailer": "v6.3.0",
"symfony/dotenv": "4.*",
"symfony/polyfill": "v1.27.0"
},
"require-dev": {

73
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "530818326ea7baa3a459b76781f0157a",
"content-hash": "2ac8346651466f89508650fddb2461db",
"packages": [
{
"name": "bugsnag/bugsnag",
@ -1173,75 +1173,6 @@
"abandoned": "symfony/mailer",
"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",
"version": "v1.27.0",
@ -1460,5 +1391,5 @@
"php": "^7.1.3"
},
"platform-dev": [],
"plugin-api-version": "2.3.0"
"plugin-api-version": "2.2.0"
}

View file

@ -29,14 +29,7 @@ $bb_cfg['tp_release_codename'] = 'Bison';
// Настройка баз данных ['db']['srv_name'] => (array) srv_cfg;
// порядок параметров srv_cfg (хост, название базы, пользователь, пароль, charset, pconnect);
$bb_cfg['db'] = [
'db' => [
env('DB_HOST', 'localhost'),
env('DB_DATABASE', 'torrentpier'),
env('DB_USERNAME', 'root'),
env('DB_PASSWORD', 'pass'),
'utf8',
false
],
'db' => ['localhost', 'torrentpier', 'root', 'root', 'utf8', false],
];
$bb_cfg['db_alias'] = [