diff --git a/composer.json b/composer.json index baa1b4a..7b0ad46 100644 --- a/composer.json +++ b/composer.json @@ -21,10 +21,7 @@ "WhatsApp\\": "classes/", "WhatsApp\\Services\\": "services/", "WhatsApp\\Queue\\": "queue/" - }, - "files": [ - "config/config.php" - ] + } }, "config": { "optimize-autoloader": true, diff --git a/config/config.php b/config/config.php index 21e7e28..45028b0 100644 --- a/config/config.php +++ b/config/config.php @@ -47,6 +47,15 @@ function loadEnvFile($path) { // Cargar .env si existe loadEnvFile(__DIR__ . '/../.env'); +// Cargar autoloader de Composer si existe (solo una vez) +$composerAutoload = __DIR__ . '/../vendor/autoload.php'; +if (file_exists($composerAutoload)) { + // Verificar que no se haya cargado ya usando una clase del autoloader + if (!class_exists('Predis\Client', false)) { + require_once $composerAutoload; + } +} + // Función helper para obtener variables de entorno if (!function_exists('env')) { function env($key, $default = null) { @@ -65,6 +74,7 @@ function isInstallationCompleted() { } // Función para obtener configuración desde base de datos +if (!function_exists('getConfigFromDB')) { function getConfigFromDB($key, $default = null) { static $configs = null; global $config_cache_cleared; @@ -108,6 +118,7 @@ function getConfigFromDB($key, $default = null) { return $configs[$key] ?? $default; } +} // end if !function_exists('getConfigFromDB') /** * Guarda una configuración en la base de datos