From 6f7c6c2ccc96699ce46d396da2b09df71d023fcd Mon Sep 17 00:00:00 2001 From: Rotimi Ade Date: Mon, 25 Sep 2017 17:51:03 -0600 Subject: [PATCH] Improved messaging for .\config\app-settings.php not found error and also now logging the error details via error_log() Bug Fix: added missing $c parameter to callable for setting the 'vespula_auth' item (for production environments) in the container in .\config\dependencies-dist.php --- config/dependencies-dist.php | 2 +- public/index-dist.php | 66 +++++++++++++++++++++++++++++++++--- 2 files changed, 63 insertions(+), 5 deletions(-) diff --git a/config/dependencies-dist.php b/config/dependencies-dist.php index ff9ba4f..491a8b3 100644 --- a/config/dependencies-dist.php +++ b/config/dependencies-dist.php @@ -133,7 +133,7 @@ //////////////////////////////////////////////////////////////////////////// // Start Vespula.Auth LDAP Authentication setup //////////////////////////////////////////////////////////////////////////// - $container['vespula_auth'] = function () { + $container['vespula_auth'] = function ($c) { //Optionally pass a maximum idle time and a time until the session //expires (in seconds) diff --git a/public/index-dist.php b/public/index-dist.php index f268934..3a270b3 100644 --- a/public/index-dist.php +++ b/public/index-dist.php @@ -88,10 +88,68 @@ function s3MVC_PrependAction2ActionMethodName($action_method_name) { $app_settings_file_path_rel = '.'.DIRECTORY_SEPARATOR."config". DIRECTORY_SEPARATOR.'app-settings.php'; $app_settings_dist_file_path_rel = '.'.DIRECTORY_SEPARATOR."config". DIRECTORY_SEPARATOR.'app-settings-dist.php'; - echo "

ERROR: `$app_settings_file_path_rel` not found!


" - . "

Please copy `$app_settings_dist_file_path_rel` to `$app_settings_file_path_rel`" - . " and configure `$app_settings_file_path_rel` to suit your application's current environment.

" - . "
Goodbye!!!"; + $app_settings_file_missing_error_page_content = <<ERROR: `$app_settings_file_path_rel` not found! +

+ Please copy `$app_settings_dist_file_path_rel` to + `$app_settings_file_path_rel` and configure + `$app_settings_file_path_rel` for your + application's current environment. +
Goodbye!!! +

+END; + + if( s3MVC_GetCurrentAppEnvironment() !== S3MVC_APP_ENV_DEV ) { + + // We are not in a dev environment. + + // 1. Make error message to be sent to the client less detailed + $app_settings_file_missing_error_page_content = <<SlimPHP 3 Skeleton MVC App Configuration Error +

+ Please check server log file for details. +
Goodbye!!! +

+END; + + // 2. Write full message to log via error_log(...) + // http://php.net/manual/en/function.error-log.php + $log_message = "ERROR:`$app_settings_file_path_rel`not found." + . " Please copy `$app_settings_dist_file_path_rel` to `$app_settings_file_path_rel` and" + . " configure `$app_settings_file_path_rel` for your application's current environment."; + + error_log ( $log_message , 0 ); // message is sent to PHP's system logger, + // using the Operating System's system logging mechanism + // or a file, depending on what the error_log configuration + // directive is set to. + + error_log ( $log_message , 4 ); // message is sent directly to the SAPI logging handler. + } + + $app_settings_file_missing_error_page = << + + SlimPHP 3 Skeleton MVC App Error + + + + $app_settings_file_missing_error_page_content + + +END; + echo $app_settings_file_missing_error_page; exit; }