--- /dev/null
+APP_ENV=development
\ No newline at end of file
"kartik-v/yii2-widget-datepicker": "dev-master",
"phpoffice/phpspreadsheet": "^2.2",
"ext-xmlreader": "*",
- "enqueue/amqp-lib": "^0.10.19"
+ "enqueue/amqp-lib": "^0.10.19",
+ "vlucas/phpdotenv": "^5.6"
},
"require-dev": {
public static function isDevEnv(): bool
{
- return getenv('DB_HOST') === 'db-yii_erp24';
+ return getenv('APP_ENV') === 'development';
}
- public static function isDevEnvironment(): bool
- {
- return getenv('XDEBUG_MODE') === 'debug';
- }
public static function sendErrorToTelegramMessage($message, $disableNotification, $isDev)
{
public static function sendMessageToTelegramClient($chatId, $message)
{
- if (self::isDevelopmentEnvironment()) {
+ if (self::isDevEnv()) {
$botToken = self::TELEGRAM_BOT_DEV;
} else {
$botToken = self::TELEGRAM_BOT_PROD;
}
- $botToken = self::TELEGRAM_BOT_PROD;
+ //$botToken = self::TELEGRAM_BOT_PROD;
$apiURL = "https://api.telegram.org/bot{$botToken}/sendMessage";
require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';
+try {
+ $dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/../');
+ $dotenv->load();
+ $dotenv->required(['APP_ENV']);
+
+ foreach ($_ENV as $key => $value) {
+ putenv("$key=$value");
+ }
+} catch (\Dotenv\Exception\InvalidPathException $e) {
+ // Логгируйте ошибку или игнорируйте, если файл не обязателен
+ error_log('Файл .env не найден: ' . $e->getMessage());
+}
+
$config = require __DIR__ . '/../config/web.php';