AloFramework documentation
  • Namespace
  • Class
  • 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    use Alo\Cache\AbstractCache;
  4    use Alo\CLI\Downloader;
  5    use Alo\Controller\AbstractController;
  6    use Alo\Controller\Router;
  7    use Alo\Cron;
  8    use Alo\cURL;
  9    use Alo\Db\AbstractDb;
 10    use Alo\Email;
 11    use Alo\File;
 12    use Alo\Profiler;
 13    use Alo\Session\AbstractSession;
 14    use Alo\SFTP;
 15    use Alo\Validators\Form;
 16    use Alo\Windows\Service;
 17 
 18    if(!defined('GEN_START')) {
 19       http_response_code(404);
 20       die();
 21    }
 22 
 23    /**
 24     * The global framework class
 25     *
 26     * @author Art <a.molcanovas@gmail.com>
 27     */
 28    class Alo {
 29 
 30       /**
 31        * Defines a session type as SQL
 32        *
 33        * @var string
 34        */
 35       const SESS_MYSQL = 'SQLSession';
 36 
 37       /**
 38        * Defines a session type as Memcached
 39        *
 40        * @var string
 41        */
 42       const SESS_MEMCACHED = 'MemcachedSession';
 43 
 44       /**
 45        * SFTP connection manager
 46        *
 47        * @var SFTP
 48        */
 49       static $sftp;
 50 
 51       /**
 52        * Code profiler
 53        *
 54        * @var Profiler
 55        */
 56       static $profiler;
 57 
 58       /**
 59        * File manager
 60        *
 61        * @var File
 62        */
 63       static $file;
 64 
 65       /**
 66        * Email manager
 67        *
 68        * @var Email
 69        */
 70       static $email;
 71 
 72       /**
 73        * Object-oriented cURL wrapper
 74        *
 75        * @var cURL
 76        */
 77       static $curl;
 78 
 79       /**
 80        * Crontab manager
 81        *
 82        * @var Cron
 83        */
 84       static $cron;
 85 
 86       /**
 87        * HTML form validator
 88        *
 89        * @var Form
 90        */
 91       static $form_validator;
 92 
 93       /**
 94        * Database connection
 95        *
 96        * @var AbstractDb
 97        */
 98       static $db;
 99 
100       /**
101        * Cache instance
102        *
103        * @var AbstractCache
104        */
105       static $cache;
106 
107       /**
108        * The session handler
109        *
110        * @var AbstractSession
111        */
112       static $session;
113 
114       /**
115        * The loaded controller
116        *
117        * @var AbstractController
118        */
119       static $controller;
120 
121       /**
122        * The routing class
123        *
124        * @var Router
125        */
126       static $router;
127 
128       /**
129        * Windows service handler
130        *
131        * @var Service
132        */
133       static $service;
134 
135       /**
136        * Download manager
137        *
138        * @var Downloader
139        */
140       static $downloader;
141 
142       /**
143        * Loads a session
144        *
145        * @param string $type The session class name - see Alo::SESS_* constants
146        *
147        * @return AbstractSession
148        * @see self::SESS_MYSQL
149        * @see self::SESS_MEMCACHED
150        */
151       static function loadSession($type = self::SESS_MYSQL) {
152          if(!self::$session) {
153             $sess          = '\Alo\Session\\' . $type;
154             self::$session = new $sess();
155          }
156 
157          return self::$session;
158       }
159 
160       /**
161        * Loads a configuration file based on environment: from DIR_SYS/config during setup & DIR_APP/config during
162        * production/development
163        *
164        * @author Art <a.molcanovas@gmail.com>
165        *
166        * @param string $path        The config file relative path without the file extension, e.g. to load a file found
167        *                            in config/db/mysql.php provide db/mysql
168        * @param bool   $return_path If set to true it will return the calculated path instead of requiring the file
169        *
170        * @return string|bool The path is $return_path is true, TRUE if it is false
171        */
172       static function loadConfig($path, $return_path = false) {
173          $dir  =
174             (defined('ENVIRONMENT') && ENVIRONMENT === ENV_SETUP ? DIR_SYS : DIR_APP) . 'config' . DIRECTORY_SEPARATOR;
175          $path = strtolower($path);
176          if(substr($path, -4) == '.php') {
177             $path = substr($path, 0, -4);
178          }
179 
180          $final_path = '';
181          if(file_exists($dir . $path . '.php')) {
182             $final_path = $dir . $path . '.php';
183          } else {
184             trigger_error('Configuration file ' .
185                           $path .
186                           ' not found in the application folder. Attempting to load from sys.',
187                           E_USER_WARNING);
188             $final_path = DIR_SYS . 'config' . DIRECTORY_SEPARATOR . $path . '.php';
189          }
190 
191          if($return_path) {
192             return $final_path;
193          } else {
194             include_once $final_path;
195 
196             return true;
197          }
198       }
199    }
200 
201    \Log::debug('Alo framework class initialised');
AloFramework documentation API documentation generated by ApiGen 2.8.0