function testConfig() { $path = \Alo::loadConfig('router', true); require $path; /** @var string $errorControllerClass */ /** @var string $defaultController */ /** @var array $routes */ $this->assertTrue(isset($errorControllerClass), '$error_controller_class not set'); $this->assertTrue(isset($defaultController), '$default_controller not set'); $this->assertTrue(isset($routes), '$routes not set'); }
<?php namespace Alo\Cache; use Redis; if (!defined('GEN_START')) { http_response_code(404); } else { \Alo::loadConfig('redis'); /** * A wrapper for PHP's Redis extension. * * @author Art <*****@*****.**> * @package Cache */ class RedisWrapper extends AbstractCache { /** * The memcached instance * * @var Redis */ protected $client; /** * Instantiates the class * * @author Art <*****@*****.**> * * @param boolean $initDefaultServer Whether to add a server on construct */ function __construct($initDefaultServer = true)
/** * Initialises the routing variables * * @author Art <*****@*****.**> * @throws CE When the config file is not found * @throws CE When $error_controller_class is not present in the config file * @throws CE When The default controller is not present in the config file * @throws CE When $routes is not a valid array * @throws CE When a route value is not an array. * @return Router */ protected function initRoutes() { $path = \Alo::loadConfig('router', true); if (!file_exists($path)) { throw new CE('Routing config file not found.', CE::E_CONFIG_NOT_FOUND); } else { require $path; if (!isset($errorControllerClass)) { throw new CE('Error controller class not found in config file.', CE::E_ERR_NOT_FOUND); } elseif (!isset($defaultController)) { throw new CE('$default_controller undefined in config file.', CE::E_DEFAULT_UNDEFINED); } elseif (!is_array(get($routes))) { throw new CE('The routes variable must be an associative array', CE::E_MALFORMED_ROUTES); } else { $this->errController = $errorControllerClass; $this->defaultController = $defaultController; foreach ($routes as $k => $v) { if (is_array($v)) { $this->routes[strtolower($k)] = array_merge(self::$routeDefaults, $v); } else { throw new CE('Route ' . $k . ' is not a valid array.', CE::E_MALFORMED_ROUTES); } } \Log::debug('Routes initialised'); } } return $this; }
<?php namespace Alo\Cache; use Memcache; use Memcached; if (!defined('GEN_START')) { http_response_code(404); } else { \Alo::loadConfig('memcached'); /** * A wrapper for PHP's Memcached extension. Will try to use the Memcached class * first, if it doesn't exist, will use Memcache. * * @author Art <*****@*****.**> * @package Cache */ class MemcachedWrapper extends AbstractCache { /** * Defines the class as Memcached * * @var int */ const CLASS_MEMCACHED = 1; /** * Defines the class as Memcache * * @var int */ const CLASS_MEMCACHE = 2;
<?php namespace Alo\Db; use PDO; if (!defined('GEN_START')) { http_response_code(404); } else { \Alo::loadConfig('db' . DIRECTORY_SEPARATOR . 'mysql'); /** * MySQL database manager * * @author Art <*****@*****.**> * @author Art <*****@*****.**> */ class MySQL extends AbstractDb { /** * The PDO instance * * @var PDO */ protected $pdo; /** * Instantiates the database connection * * @author Art <*****@*****.**> * * @param string $ip The IP address to use * @param int $port The port to use * @param string $user The username
<?php namespace Alo; use PHPMailer; if (!defined('GEN_START')) { http_response_code(404); } else { require_once DIR_SYS . 'external' . DIRECTORY_SEPARATOR . 'email' . DIRECTORY_SEPARATOR . 'class.phpmailer.php'; require_once DIR_SYS . 'external' . DIRECTORY_SEPARATOR . 'email' . DIRECTORY_SEPARATOR . 'PHPMailerAutoload.php'; \Alo::loadConfig('email'); /** * Mail wrapper for the external PHPMailer library * * @author Art <*****@*****.**> * @link https://github.com/PHPMailer/PHPMailer */ class Email extends PHPMailer { /** * Static reference to the last instance of the class * * @var Email */ static $this; /** * Array of debug outputs, each send operation representing a key/value pair * * @var array */ protected $debugOutput;