From 38e1d4fd423017ee9b5d282a1366fabcc34128c2 Mon Sep 17 00:00:00 2001 From: synox Date: Sun, 10 Mar 2019 22:17:59 +0700 Subject: [PATCH] CHANGE: detect missing imap extension and config error --- CHANGELOG.md | 1 + README.md | 5 +++++ src/boot.php | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6597ec4..646082d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. The format ### Changed - find config.php automatically in current and parent directories. Show error message if not found. - use local CSS/JS instead of CDN +- detect missing imap extension and config error ## [0.2.1] - 2018-07-01 diff --git a/README.md b/README.md index 3e00d1e..f4434b6 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,11 @@ Install php dependecies: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); +## Testing on MacOs + * brew install php + * brew install kabel/php-ext/php-imap + * php -S localhost:8000 -t src + ## Credit :thumbsup: diff --git a/src/boot.php b/src/boot.php index 86ae958..f02b0f0 100644 --- a/src/boot.php +++ b/src/boot.php @@ -3,6 +3,8 @@ if (version_compare(phpversion(), '7.2', '<')) { die("ERROR! The php version isn't high enough, you need at least 7.2 to run this application! But you have: " . phpversion()); } +extension_loaded("imap") || die('ERROR: IMAP extension not loaded. Please see the installation instructions in the README.md'); + /** * searches for a config-file in the current and parent directories until found. * @return path to found config file, or FALSE otherwise. @@ -32,6 +34,9 @@ function load_config(){ $file = find_config(); if ( $file !== FALSE) { require_once($file); + if(!isset($config) || !is_array($config)){ + die('ERROR: Config file is invalid. Please see the installation instructions in the README.md'); + } } else { die('ERROR: Config file not found. Please see the installation instructions in the README.md'); }