Skip to content

Commit

Permalink
Improved messaging for .\config\app-settings.php not found error and …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
rotexdegba committed Sep 25, 2017
1 parent 54f06e0 commit 6f7c6c2
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 5 deletions.
2 changes: 1 addition & 1 deletion config/dependencies-dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
66 changes: 62 additions & 4 deletions public/index-dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<h1>ERROR: <strong>`$app_settings_file_path_rel`</strong> not found!</h1> <br>"
. "<p>Please copy <strong>`$app_settings_dist_file_path_rel`</strong> to <strong>`$app_settings_file_path_rel`</strong>"
. " and configure <strong>`$app_settings_file_path_rel`</strong> to suit your application's current environment.</p>"
. "<br>Goodbye!!!";
$app_settings_file_missing_error_page_content = <<<END
<h1>ERROR: <strong>`$app_settings_file_path_rel`</strong> not found!</h1>
<p>
Please copy <strong>`$app_settings_dist_file_path_rel`</strong> to
<strong>`$app_settings_file_path_rel`</strong> and configure
<strong>`$app_settings_file_path_rel`</strong> for your
application's current environment.
<br>Goodbye!!!
</p>
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 = <<<END
<h1>SlimPHP 3 Skeleton MVC App Configuration Error</h1>
<p>
Please check server log file for details.
<br>Goodbye!!!
</p>
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 = <<<END
<html>
<head>
<title>SlimPHP 3 Skeleton MVC App Error</title>
<style>
body{
margin:0;
padding:30px;
font:12px/1.5 Helvetica,Arial,Verdana,sans-serif;
}
h1{
margin:0;
font-size:48px;
font-weight:normal;
line-height:48px;
}
</style>
</head>
<body>
$app_settings_file_missing_error_page_content
</body>
</html>
END;
echo $app_settings_file_missing_error_page;
exit;
}

Expand Down

0 comments on commit 6f7c6c2

Please sign in to comment.