AloFramework documentation
  • Namespace
  • Function
  • Tree
  • Deprecated
  • Todo
  • Download

Namespaces

  • Alo
    • Cache
    • CLI
    • Controller
    • Db
    • Exception
    • FileSystem
    • Session
    • Statics
    • Test
    • Validators
    • Windows
  • Controller
  • None
  • PHP

Classes

  • Alo
  • Log

Functions

  • debug
  • get
  • getallheaders
  • lite_debug
  • server_is_windows
  • timestamp_precise
  1 <?php
  2 
  3    if (!defined('GEN_START')) {
  4       http_response_code(404);
  5       die();
  6    }
  7 
  8    ob_start();
  9    require_once DIR_SYS . 'core' . DIRECTORY_SEPARATOR . 'log.php';
 10    include_once DIR_SYS . 'external' . DIRECTORY_SEPARATOR . 'kint' . DIRECTORY_SEPARATOR . '_main.php';
 11    require_once DIR_SYS . 'core' . DIRECTORY_SEPARATOR . 'handler.php';
 12 
 13    spl_autoload_register('\Alo\Handler::autoloader');
 14    set_error_handler('\Alo\Handler::error', ini_get('error_reporting'));
 15    set_exception_handler('\Alo\Handler::ecxeption');
 16 
 17    /**
 18     * A shortcut to isset($var) ? $var : null
 19     *
 20     * @author Art <a.molcanovas@gmail.com>
 21     * @param mixed $var The variable to "return"
 22     * @return mixed
 23     */
 24    function get(&$var) {
 25       return isset($var) ? $var : null;
 26    }
 27 
 28    /**
 29     * Returns a debug string of the passed on variables
 30     *
 31     * @return string
 32     */
 33    function debug() {
 34       if (!Kint::enabled()) {
 35          return null;
 36       } else {
 37          ob_start();
 38          $args = func_get_args();
 39          call_user_func_array(['Kint', 'dump'], $args);
 40 
 41          return ob_get_clean();
 42       }
 43    }
 44 
 45    /**
 46     * Check if the server is running Windows
 47     *
 48     * @author Art <a.molcanovas@gmail.com>
 49     * @return bool
 50     */
 51    function server_is_windows() {
 52       return substr(strtoupper(php_uname('s')), 0, 3) === 'WIN';
 53    }
 54 
 55    /**
 56     * Returns a lite debug string of passed on variables
 57     *
 58     * @return string
 59     */
 60    function lite_debug() {
 61       if (!Kint::enabled()) {
 62          return '';
 63       } else {
 64          ob_start();
 65          $argv = func_get_args();
 66          echo '<pre>';
 67          foreach ($argv as $k => $v) {
 68             $k && print("\n\n");
 69             echo kintLite($v);
 70          }
 71          echo '</pre>' . "\n";
 72 
 73          return ob_get_clean();
 74       }
 75    }
 76 
 77    /**
 78     * Returns a very precise timestamp
 79     *
 80     * @author Art <a.molcanovas@gmail.com>
 81     * @param float $microtime Optionally, supply your own microtime
 82     * @return string Y-m-d H:i:s:{milliseconds}
 83     */
 84    function timestamp_precise($microtime = null) {
 85       if (!$microtime) {
 86          $microtime = microtime(true);
 87       }
 88       $t = explode('.', $microtime);
 89 
 90       return date('Y-m-d H:i:s', $t[0]) . ':' . round($t[1] / 10);
 91    }
 92 
 93    if (!function_exists('getallheaders')) {
 94 
 95       /**
 96        * Implement getallheaders() for non-apache servers
 97        *
 98        * @author Art <a.molcanovas@gmail.com>
 99        * @return array
100        */
101       function getallheaders() {
102          $headers = [];
103          foreach ($_SERVER as $name => $value) {
104             if (substr($name, 0, 5) == 'HTTP_') {
105                $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
106             }
107          }
108 
109          return $headers;
110       }
111    }
112 
113    require_once DIR_SYS . 'core' . DIRECTORY_SEPARATOR . 'alo.php';
114 
115    if (!defined('PHPUNIT_RUNNING')) {
116       Alo::$router = new Alo\Controller\Router();
117       Alo::$router->init();
118    }
AloFramework documentation API documentation generated by ApiGen 2.8.0