diff --git a/config/config.example.ini b/config/config.example.ini index cd41d3c..0b24ba2 100644 --- a/config/config.example.ini +++ b/config/config.example.ini @@ -8,29 +8,22 @@ ; but must EXCLUDE the .php file extension. (I recommend sticking with the bundled mysql library) driver = mysql -; Use a Unix system socket (if the library supports it), doesn't work on Windows servers. -unixsocket = false - -; URI to SQL server (usually localhost or 127.0.0.1) or in the case that you're using Unix sockets -; the path to the socket. -host = localhost - -; Port for the SQL server, ignored if Unix sockets are used. Should be 3306. -port = 3306 - ; Username used to authenticate with the SQL server username = sakura ; Password for the same purpose password = "password" -; Database (not table) name used. -database = sakura - ; Table prefix used. prefix = sakura_ +[dsn] +host=localhost +port=3306 +dbname=sakura + + ; Data files relative to the root directory [data] ; JSON file containing ISO 3166 country codes diff --git a/libraries/Config.php b/libraries/Config.php index 355251b..ed8f475 100644 --- a/libraries/Config.php +++ b/libraries/Config.php @@ -1,7 +1,7 @@ */ @@ -17,21 +17,21 @@ class Config { /** * Container for the parsed local configuration. - * + * * @var array */ private static $local = []; /** * Cache for the configuration stored in the database. - * + * * @var array */ private static $database = []; /** * Initialiser, parses the local configuration. - * + * * @param string $local Path to the configuration file. */ public static function init($local) @@ -59,10 +59,10 @@ class Config /** * Get a value from the local configuration file. - * + * * @param string $key Configuration section. * @param string $subkey Configuration key. - * + * * @return array|string Configuration value. */ public static function local($key, $subkey = null) @@ -88,13 +88,13 @@ class Config /** * Get a configuration value from the database. - * + * * @param string $key Configuration key. - * @param bool $returnNull Unused value, only exists to prevent explosions. - * + * @param string $default Value that gets used when the value doesn't exist. + * * @return string Configuration value. */ - public static function get($key, $returnNull = false) + public static function get($key, $default = null) { // Check if the key that we're looking for exists if (array_key_exists($key, self::$database)) { @@ -112,12 +112,11 @@ class Config } } - // Then return the value - trigger_error( - 'Unable to get configuration value "' . $key . '"', - E_USER_ERROR - ); - return null; + // If we fell all the way down here set the bundled default value + Config::set($key, $default); + + // And then return default that value + return $default; } public static function set($key, $value) diff --git a/libraries/Console/Command/ServeCommand.php b/libraries/Console/Command/ServeCommand.php index cdb8104..0b44ad2 100644 --- a/libraries/Console/Command/ServeCommand.php +++ b/libraries/Console/Command/ServeCommand.php @@ -1,7 +1,7 @@