linux fixes (it's opposite day)

This commit is contained in:
flash 2016-02-20 12:20:58 +01:00
parent 3d4f1c3187
commit b977c8422b
4 changed files with 28 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) ; but must EXCLUDE the .php file extension. (I recommend sticking with the bundled mysql library)
driver = mysql 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 used to authenticate with the SQL server
username = sakura username = sakura
; Password for the same purpose ; Password for the same purpose
password = "password" password = "password"
; Database (not table) name used.
database = sakura
; Table prefix used. ; Table prefix used.
prefix = sakura_ prefix = sakura_
[dsn]
host=localhost
port=3306
dbname=sakura
; Data files relative to the root directory ; Data files relative to the root directory
[data] [data]
; JSON file containing ISO 3166 country codes ; JSON file containing ISO 3166 country codes

View file

@ -1,7 +1,7 @@
<?php <?php
/** /**
* Holds the configuration manager. * Holds the configuration manager.
* *
* @package Sakura * @package Sakura
*/ */
@ -9,7 +9,7 @@ namespace Sakura;
/** /**
* Handles both the local and database stored configuration sides of Sakura. * Handles both the local and database stored configuration sides of Sakura.
* *
* @package Sakura * @package Sakura
* @author Julian van de Groep <me@flash.moe> * @author Julian van de Groep <me@flash.moe>
*/ */
@ -17,21 +17,21 @@ class Config
{ {
/** /**
* Container for the parsed local configuration. * Container for the parsed local configuration.
* *
* @var array * @var array
*/ */
private static $local = []; private static $local = [];
/** /**
* Cache for the configuration stored in the database. * Cache for the configuration stored in the database.
* *
* @var array * @var array
*/ */
private static $database = []; private static $database = [];
/** /**
* Initialiser, parses the local configuration. * Initialiser, parses the local configuration.
* *
* @param string $local Path to the configuration file. * @param string $local Path to the configuration file.
*/ */
public static function init($local) public static function init($local)
@ -59,10 +59,10 @@ class Config
/** /**
* Get a value from the local configuration file. * Get a value from the local configuration file.
* *
* @param string $key Configuration section. * @param string $key Configuration section.
* @param string $subkey Configuration key. * @param string $subkey Configuration key.
* *
* @return array|string Configuration value. * @return array|string Configuration value.
*/ */
public static function local($key, $subkey = null) public static function local($key, $subkey = null)
@ -88,13 +88,13 @@ class Config
/** /**
* Get a configuration value from the database. * Get a configuration value from the database.
* *
* @param string $key Configuration key. * @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. * @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 // Check if the key that we're looking for exists
if (array_key_exists($key, self::$database)) { if (array_key_exists($key, self::$database)) {
@ -112,12 +112,11 @@ class Config
} }
} }
// Then return the value // If we fell all the way down here set the bundled default value
trigger_error( Config::set($key, $default);
'Unable to get configuration value "' . $key . '"',
E_USER_ERROR // And then return default that value
); return $default;
return null;
} }
public static function set($key, $value) public static function set($key, $value)

View file

@ -1,7 +1,7 @@
<?php <?php
/** /**
* Holds the serve command controller. * Holds the serve command controller.
* *
* @package Sakura * @package Sakura
*/ */
@ -18,6 +18,6 @@ class ServeCommand extends Command
public function execute() 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'));
} }
} }

View file

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