diff --git a/env.sample.php b/env.sample.php index 9ba9898..b4fe4fd 100644 --- a/env.sample.php +++ b/env.sample.php @@ -7,7 +7,13 @@ */ $SETTINGS = [ + // If true, PHP errors and warnings are outputted, screwing up the JSON. + // Makes it easy to debug though! "debugmode" => true, + // If this is true and the database isn't configured, everything crashes. + // set to false if no endpoints require a database, or if Medoo isn't being used + // to access the database. + "require_database" => false, "database" => [ "database_type" => "mysql", "database_name" => "mysql", @@ -16,6 +22,8 @@ $SETTINGS = [ "password" => "", "charset" => "utf8" ], + // If memcached is available, enable it. Otherwise a non-persistent shim is used, + // which is pointless. See lib/Memcache.lib.php. "memcached" => [ "enable" => true, "server" => "127.0.0.1", @@ -26,6 +34,8 @@ $SETTINGS = [ // Include trailing slash "urlbase" => "/", + + // Third party API keys and configs for various endpoints go here "openweathermap_appid" => "", "weather_summary_hours" => 8, diff --git a/required.php b/required.php index 59a0c93..abdca18 100644 --- a/required.php +++ b/required.php @@ -43,12 +43,16 @@ if (envhas("timezone")) { // Initialize database driver use Medoo\Medoo; + $database; try { $database = new Medoo(env("database", [])); } catch (Exception $ex) { - http_response_code(500); - Logger::log("Database error: $ex"); + if (env("require_database")) { + http_response_code(500); + Logger::log("Database error: $ex"); + exit("Database error."); + } } $memcacheconfig = env("memcached", [