This commit is contained in:
flash 2016-02-23 15:45:07 +01:00
commit 562294412a
5 changed files with 29 additions and 33 deletions

View file

@ -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

View file

@ -90,11 +90,11 @@ 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)

View file

@ -18,6 +18,6 @@ class ServeCommand extends Command
public function execute()
{
exec(PHP_BINDIR . '\php -S localhost:8000 -t ' . addslashes(ROOT . 'public/') . ' ' . addslashes(ROOT . 'server.php'));
exec(PHP_BINDIR . '/php -S localhost:8000 -t ' . addslashes(ROOT . 'public/') . ' ' . addslashes(ROOT . 'server.php'));
}
}

1
mahou Normal file → Executable file
View file

@ -1,3 +1,4 @@
#!/usr/bin/env php
<?php
/*
* Sakura Mahou

View file

@ -37,11 +37,14 @@ if (!@include_once ROOT . 'vendor/autoload.php') {
// Setup the autoloader
spl_autoload_register(function ($className) {
// Replace \ with /
$className = str_replace('\\', '/', $className);
// Create a throwaway count variable
$i = 1;
// Replace the sakura namespace with the libraries directory
$className = str_replace('Sakura\\', 'libraries/', $className, $i);
$className = str_replace('Sakura/', 'libraries/', $className, $i);
// Require the file
require_once ROOT . $className . '.php';