Guest User

Untitled

a guest
Aug 2nd, 2014
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.14 KB | None | 0 0
  1. #Liberry/Config.php
  2. <?php
  3.  
  4. $dev = true;
  5.  
  6. if ($dev) {
  7.     error_reporting(E_ALL);
  8. }
  9.  
  10. define('ABSPATH', __DIR__ );
  11. define('GZ_USER_AGENT', 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.4) Gecko/20091016 Firefox/3.5.4 (.NET CLR 3.5.30729)');
  12.  
  13. require_once ABSPATH . '/Utilities/Loader.php';
  14.  
  15. $loader = new \Liberry\Utilities\Loader();
  16. $loader->register();
  17.  
  18. #Liberry/Utilities/Loader.php
  19. <?php
  20.  
  21. namespace Liberry\Utilities;
  22.  
  23. final class Loader
  24. {
  25.     private $_fileExtension = '.php';
  26.     private $_namespace;
  27.     private $_includePath;
  28.     private $_namespaceSeparator = '\\';
  29.  
  30.     public function __constructor($ns = null, $includePath = null)
  31.     {
  32.         $this->_namespace = $ns;
  33.         $this->_includePath = $includePath;
  34.     }
  35.  
  36.     public function register()
  37.     {
  38.         spl_autoload_register(array($this, 'loadClass'));
  39.     }
  40.  
  41.     public function loadClass($className)
  42.     {
  43.         if (null === $this->_namespace || $this->_namespace.$this->_namespaceSeparator === substr($className, 0, strlen($this->_namespace.$this->_namespaceSeparator))) {
  44.             $fileName = '';
  45.             $namespace = '';
  46.             if (false !== ($lastNsPos = strripos($className, $this->_namespaceSeparator))) {
  47.                 $namespace = substr($className, 0, $lastNsPos);
  48.                 $className = substr($className, $lastNsPos + 1);
  49.                 $fileName = str_replace($this->_namespaceSeparator, DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
  50.             }
  51.             $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . $this->_fileExtension;
  52.  
  53. //            require ($this->_includePath !== null ? $this->_includePath . DIRECTORY_SEPARATOR : '') . $fileName;
  54.             echo ($this->_includePath !== null ? $this->_includePath . DIRECTORY_SEPARATOR : '') . $fileName;
  55.         }
  56.     }
  57. }
  58.  
  59. #Liberry/Core/JobConfig.php
  60. <?php
  61.  
  62. namespace Liberry\Core;
  63.  
  64.  
  65. class JobConfig {
  66.     public function __contructor()
  67.     {
  68.         echo 'this is the job config';
  69.     }
  70. }
  71.  
  72. #Liberry/Scheduled/testJob.php
  73. <?php
  74.  
  75. require_once dirname(__DIR__) . '/Config.php';
  76.  
  77. $conf = new \Liberry\Core\JobConfig();
Advertisement
Add Comment
Please, Sign In to add comment