Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Liberry/Config.php
- <?php
- $dev = true;
- if ($dev) {
- error_reporting(E_ALL);
- }
- define('ABSPATH', __DIR__ );
- 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)');
- require_once ABSPATH . '/Utilities/Loader.php';
- $loader = new \Liberry\Utilities\Loader();
- $loader->register();
- #Liberry/Utilities/Loader.php
- <?php
- namespace Liberry\Utilities;
- final class Loader
- {
- private $_fileExtension = '.php';
- private $_namespace;
- private $_includePath;
- private $_namespaceSeparator = '\\';
- public function __constructor($ns = null, $includePath = null)
- {
- $this->_namespace = $ns;
- $this->_includePath = $includePath;
- }
- public function register()
- {
- spl_autoload_register(array($this, 'loadClass'));
- }
- public function loadClass($className)
- {
- if (null === $this->_namespace || $this->_namespace.$this->_namespaceSeparator === substr($className, 0, strlen($this->_namespace.$this->_namespaceSeparator))) {
- $fileName = '';
- $namespace = '';
- if (false !== ($lastNsPos = strripos($className, $this->_namespaceSeparator))) {
- $namespace = substr($className, 0, $lastNsPos);
- $className = substr($className, $lastNsPos + 1);
- $fileName = str_replace($this->_namespaceSeparator, DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
- }
- $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . $this->_fileExtension;
- // require ($this->_includePath !== null ? $this->_includePath . DIRECTORY_SEPARATOR : '') . $fileName;
- echo ($this->_includePath !== null ? $this->_includePath . DIRECTORY_SEPARATOR : '') . $fileName;
- }
- }
- }
- #Liberry/Core/JobConfig.php
- <?php
- namespace Liberry\Core;
- class JobConfig {
- public function __contructor()
- {
- echo 'this is the job config';
- }
- }
- #Liberry/Scheduled/testJob.php
- <?php
- require_once dirname(__DIR__) . '/Config.php';
- $conf = new \Liberry\Core\JobConfig();
Advertisement
Add Comment
Please, Sign In to add comment