/**
  * @param string $className
  * @dataProvider getLoadNonexistentClassTests
  */
 public function testLoadNonexistentClass($className)
 {
     $loader = new Psr4ClassLoader();
     $loader->addPrefix('Acme\\DemoLib', __DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'psr-4');
     $loader->loadClass($className);
     $this->assertFalse(class_exists($className), sprintf('loadClass() should not load %s', $className));
 }
 /**
  * @param array $paths
  */
 private function setupAutoloader(array $paths = [])
 {
     require_once __DIR__ . '/src/ClassLoader/Psr4ClassLoader.php';
     $loader = new Psr4ClassLoader();
     foreach ($paths as $ns => $path) {
         foreach ($path as $k => $dir) {
             $loader->addPrefix($ns, implode(DIRECTORY_SEPARATOR, $dir));
         }
     }
     $loader->register();
 }
Beispiel #3
0
 /**
  * @param array $dirs [[prefix, path, <recursive>], ...]
  * @return Psr4ClassLoader
  */
 public function loadClass(array $dirs)
 {
     $loader = new Psr4ClassLoader();
     $root = realpath($this->root);
     $paths = [];
     foreach ($dirs as $d) {
         if (is_array($d) && count($d) > 1) {
             $prefix = $d[0];
             $path = $d[1];
             $r = false;
             if (count($d) > 2 && $d[2]) {
                 $r = true;
             }
             $p = $this->getClassPath($root, $prefix, $path, $r);
             $paths = array_merge($paths, $p);
         }
     }
     foreach ($paths as $p) {
         $loader->addPrefix($p['prefix'], $p['path']);
     }
     $loader->register();
     return $loader;
 }
<?php

require_once __DIR__ . '/vendor/symfony/class-loader/Psr4ClassLoader.php';
use MF\App;
use MF\Render\MessageRender;
use Symfony\Component\ClassLoader\Psr4ClassLoader;
$loader = new Psr4ClassLoader();
$loader->addPrefix('MF', __DIR__ . '/src');
$loader->register();
$app = new App(new MessageRender('Hello world by Psr4ClassLoader!'));
$app->renderResponse();
Beispiel #5
0
 */
error_reporting(E_ALL);
/**
 * 是否显示错误
 */
ini_set('display_errors', 1);
/**
 * 开启 Session
 */
if (PHP_SESSION_NONE === session_status()) {
    session_start();
}
/**
 * 类加载器(Psr4)
 */
require __DIR__ . '/Psr4ClassLoader.php';
use Symfony\Component\ClassLoader\Psr4ClassLoader;
$loader = new Psr4ClassLoader();
$loader->addPrefix('Thenbsp\\Wechat', '../');
$loader->addPrefix('Endroid\\QrCode', '../Qrcode/src');
$loader->register();
/**
 * 公众号配置
 */
define('APPID', 'wx345f3830c28971f4');
define('APPSECRET', '56af198c87561264ca5756efc6389d96');
/**
 * 商户配置
 */
define('MCHID', '1241642202');
define('MCHKEY', '28fa332f275277df2b0317b1eb22fbb4');
Beispiel #6
0
<?php

use Symfony\Component\ClassLoader\Psr4ClassLoader;
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
    require __DIR__ . '/../vendor/autoload.php';
} else {
    require __DIR__ . '/../lib/ClassLoader/Psr4ClassLoader.php';
    $loader = new Psr4ClassLoader();
    $loader->addPrefix('Maiorano\\Shortcodes\\', __DIR__ . '/../src');
    $loader->register();
}
Beispiel #7
0
<?php

require_once __DIR__ . '/../../lib/ClassLoader/Psr4ClassLoader.php';
use Symfony\Component\ClassLoader\Psr4ClassLoader as ClassLoader;
use Hyla\Config\Conf;
$loader = new ClassLoader();
$loader->addPrefix('Hyla', dirname(__DIR__));
$loader->addPrefix('Hyla', dirname(dirname(dirname(__DIR__))) . '/test/core');
$loader->addPrefix('HylaComponents', dirname(dirname(__DIR__)) . '/components');
$loader->addPrefix('HylaPlugins', dirname(dirname(__DIR__)) . '/plugins');
$loader->register();
Conf::initApp();
$app = Conf::get('app');
if (!empty($app)) {
    $loader->addPrefix($app['name'], Conf::$rootDir . $app['path'] . '/src');
}
Beispiel #8
0
 /**
  * Adds concrete5's core autoloading prefixes
  *
  * * The following prefixes are registered:
  * <ul>
  * <li>`Concrete\StartingPointPackage` -> `concrete/config/install/packages`</li>
  * <li>`Concrete\Attribute` -> `concrete/attributes`</li>
  * <li>`Concrete\Authentication` -> `concrete/authentication`</li>
  * <li>`Concrete\Block` -> `concrete/blocks`</li>
  * <li>`Concrete\Theme` -> `concrete/themes`</li>
  * <li>`Concrete\Controller\PageType` -> `concrete/controllers/page_types`</li>
  * <li>`Concrete\Controller` -> `concrete/controllers`</li>
  * <li>`Concrete\Job` -> `concrete/jobs`</li>
  * <li>`Concrete\Core` -> `concrete/src`</li>
  * <li>`Application\StartingPointPackage` -> `application/config/install/packages`</li>
  * <li>`Application\Attribute` -> `application/attributes`</li>
  * <li>`Application\Authentication` -> `application/authentication`</li>
  * <li>`Application\Block` -> `application/blocks`</li>
  * <li>`Application\Theme` -> `application/themes`</li>
  * <li>`Application\Controller\PageType` -> `application/controllers/page_types`</li>
  * <li>`Application\Controller` -> `application/controllers`</li>
  * <li>`Application\Job` -> `application/jobs`</li>
  * <li>`Application\Core` -> `application/src`</li>
  * </ul>
  *
  * The application namespace can be customized by setting `namespace` in the application's `config/app.php`.
  */
 protected function setupFileAutoloader()
 {
     $symfonyLoader = new ModifiedPSR4ClassLoader();
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\StartingPointPackage', DIR_BASE_CORE . '/config/install/' . DIRNAME_PACKAGES);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Attribute', DIR_BASE_CORE . '/' . DIRNAME_ATTRIBUTES);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\MenuItem', DIR_BASE_CORE . '/' . DIRNAME_MENU_ITEMS);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Authentication', DIR_BASE_CORE . '/' . DIRNAME_AUTHENTICATION);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Block', DIR_BASE_CORE . '/' . DIRNAME_BLOCKS);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Theme', DIR_BASE_CORE . '/' . DIRNAME_THEMES);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Controller\\PageType', DIR_BASE_CORE . '/' . DIRNAME_CONTROLLERS . '/' . DIRNAME_PAGE_TYPES);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Controller', DIR_BASE_CORE . '/' . DIRNAME_CONTROLLERS);
     $symfonyLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Job', DIR_BASE_CORE . '/' . DIRNAME_JOBS);
     $namespace = 'Application';
     $app_config_path = DIR_APPLICATION . '/config/app.php';
     $provideCoreExtensionAutoloaderMapping = false;
     if (file_exists($app_config_path)) {
         $app_config = (require $app_config_path);
         if (isset($app_config['namespace'])) {
             $namespace = $app_config['namespace'];
         }
         if (isset($app_config['provide_core_extension_autoloader_mapping'])) {
             $provideCoreExtensionAutoloaderMapping = true;
         }
     }
     $symfonyLoader->addPrefix($namespace . '\\StartingPointPackage', DIR_APPLICATION . '/config/install/' . DIRNAME_PACKAGES);
     $symfonyLoader->addPrefix($namespace . '\\Attribute', DIR_APPLICATION . '/' . DIRNAME_ATTRIBUTES);
     $symfonyLoader->addPrefix($namespace . '\\MenuItem', DIR_APPLICATION . '/' . DIRNAME_MENU_ITEMS);
     $symfonyLoader->addPrefix($namespace . '\\Authentication', DIR_APPLICATION . '/' . DIRNAME_AUTHENTICATION);
     $symfonyLoader->addPrefix($namespace . '\\Block', DIR_APPLICATION . '/' . DIRNAME_BLOCKS);
     $symfonyLoader->addPrefix($namespace . '\\Theme', DIR_APPLICATION . '/' . DIRNAME_THEMES);
     $symfonyLoader->addPrefix($namespace . '\\Controller\\PageType', DIR_APPLICATION . '/' . DIRNAME_CONTROLLERS . '/' . DIRNAME_PAGE_TYPES);
     $symfonyLoader->addPrefix($namespace . '\\Controller', DIR_APPLICATION . '/' . DIRNAME_CONTROLLERS);
     $symfonyLoader->addPrefix($namespace . '\\Job', DIR_APPLICATION . '/' . DIRNAME_JOBS);
     $symfonyLoader->register();
     $strictLoader = new SymfonyClassLoader();
     $strictLoader->addPrefix(NAMESPACE_SEGMENT_VENDOR . '\\Core', DIR_BASE_CORE . '/' . DIRNAME_CLASSES);
     if ($provideCoreExtensionAutoloaderMapping) {
         $strictLoader->addPrefix($namespace, DIR_APPLICATION . '/' . DIRNAME_CLASSES . '/Concrete');
     } else {
         $strictLoader->addPrefix($namespace . '\\Src', DIR_APPLICATION . '/' . DIRNAME_CLASSES);
     }
     $strictLoader->register();
 }
<?php

use Symfony\Component\ClassLoader\Psr4ClassLoader;
if (!class_exists('\\Symfony\\Component\\ClassLoader\\Psr4ClassLoader')) {
    require_once dirname(__FILE__) . '/vendor/Symfony/Component/ClassLoader/Psr4ClassLoader.php';
}
$loader = new Psr4ClassLoader();
$loader->addPrefix('MightyDev', dirname(__FILE__) . '/vendor/MightyDev');
$loader->addPrefix('MightyDev\\Templating', dirname(__FILE__) . '/vendor/MightyDev/Templating');
$loader->addPrefix('MightyDev\\WordPress', dirname(__FILE__) . '/vendor/MightyDev/WordPress');
$loader->addPrefix('MightyDev\\WordPress\\Plugin', dirname(__FILE__) . '/vendor/MightyDev/WordPress/Plugin');
$loader->addPrefix('MightyDev\\WordPress\\Plugin', dirname(__FILE__));
$loader->addPrefix('WPAlchemy', dirname(__FILE__) . '/vendor/WPAlchemy');
$loader->register();
if (!class_exists('\\Twig_Autoloader')) {
    require_once dirname(__FILE__) . '/vendor/Twig/Autoloader.php';
    Twig_Autoloader::register();
}
if (!class_exists('\\WPAlchemy_MetaBox')) {
    require_once dirname(__FILE__) . '/vendor/WPAlchemy/MetaBox.php';
}
require_once dirname(__FILE__) . '/shortcode.php';
require_once dirname(__FILE__) . '/post-type-edit.php';
Beispiel #10
0
 * @author Norman Malessa <*****@*****.**>
 * @copyright 2014 Norman Malessa <*****@*****.**>
 * @license http://www.opensource.org/licenses/mit-license.php The MIT License, see LICENSE.txt
 */
use Pids\Controller;
use Monolog\Logger;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Processor\WebProcessor;
use Monolog\Processor\MemoryUsageProcessor;
use Symfony\Component\ClassLoader\Psr4ClassLoader;
// this makes our life easier when dealing with paths. Everything is relative to the application root now.
chdir(dirname(__DIR__));
// initialize autoloading
require __DIR__ . '/../vendor/autoload.php';
$loader = new Psr4ClassLoader();
$loader->addPrefix('Pids\\', 'src' . DIRECTORY_SEPARATOR . 'Pids');
$loader->register();
// load config
$aConfig = (include_once 'config' . DIRECTORY_SEPARATOR . 'config.php');
// create logger
$oLogger = new Logger('pids');
if ($aConfig['logging']['enable']) {
    $oHandler = new RotatingFileHandler('log' . DIRECTORY_SEPARATOR . 'access.log', 7, $aConfig['logging']['level']);
    $oHandler->pushProcessor(new WebProcessor());
    if ($aConfig['logging']['level'] == Logger::DEBUG) {
        $oHandler->pushProcessor(new MemoryUsageProcessor());
    }
    $oLogger->pushHandler($oHandler);
}
// create controller and process request
$oController = new Controller($aConfig, $oLogger);
Beispiel #11
0
<?php

use Symfony\Component\ClassLoader\Psr4ClassLoader;
$base = dirname(__DIR__);
require_once $base . "/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Psr4ClassLoader.php";
require_once $base . "/vendor/autoload.php";
$loader = new Psr4ClassLoader();
$loader->addPrefix("shackles", $base . "/lib");
$loader->register();
<?php

/**
 * Summary
 *
 * Description.
 *
 * @since 0.9.0
 *
 * @package
 * @subpackage 
 *
 * @author nguyenvanduocit
 */
require_once VNO_DIR . '/lib/Psr4ClassLoader.php';
use Symfony\Component\ClassLoader\Psr4ClassLoader;
$loader = new Psr4ClassLoader();
$loader->addPrefix('VN_OEmbed', VNO_DIR);
$loader->register();
<?php

/**
 * Created by PhpStorm.
 * User: dima
 * Date: 17.09.15
 * Time: 21:55
 */
namespace {
    use Symfony\Component\ClassLoader\Psr4ClassLoader;
    require_once __DIR__ . '/../vendor/autoload.php';
    $loader = new Psr4ClassLoader();
    $loader->addPrefix('DG\\SymfonyCert\\', __DIR__ . '/../src');
    $loader->register();
}
Beispiel #14
0
 public function registerHelpers()
 {
     Core::bind('helper/blogify', 'Concrete\\Package\\Problog\\Controller\\Helpers\\Blogify');
     Core::bind('helper/blog_actions', 'Concrete\\Package\\Problog\\Controller\\Helpers\\BlogActions');
     $psr4_loader = new Psr4ClassLoader();
     $psr4_loader->addPrefix('\\Concrete\\Package\\Problog\\src', __DIR__ . '/src');
     $psr4_loader->register();
 }
namespace {
    require_once __DIR__ . '/vendor/autoload.php';
    use Dima\Legacy\TestClass as TestLoadedByMap;
    use Dima\Test as TestPsr0;
    use Symfony\Component\ClassLoader\ClassLoader;
    use Symfony\Component\ClassLoader\ClassMapGenerator;
    use Symfony\Component\ClassLoader\MapClassLoader;
    use Symfony\Component\ClassLoader\Psr4ClassLoader;
    use Symfony\Component\ClassLoader\XcacheClassLoader;
    use DG\SymfonyCert\Controller\HomeController;
    $psr0Loader = new ClassLoader();
    $psr0Loader->addPrefix('Dima', __DIR__ . '/srcPsr0');
    $cachedLoader = new XcacheClassLoader(sha1(__FILE__), $psr0Loader);
    $cachedLoader->register();
    $psr0Loader->unregister();
    $psr4Loader = new Psr4ClassLoader();
    $psr4Loader->addPrefix('DG\\SymfonyCert\\', __DIR__ . '/src');
    $psr4Loader->register();
    $mapLoader = new MapClassLoader(['Dima\\Legacy\\TestClass' => __DIR__ . '/srcPsr0/TestClass.php']);
    $mapLoader->register();
    ClassMapGenerator::dump(__DIR__ . '/srcThirdParty', __DIR__ . '/class_map.php');
    $classMap = (include __DIR__ . '/class_map.php');
    $mapLoader2 = new MapClassLoader($classMap);
    $mapLoader2->register();
    //Psr0 loader + XCache
    TestPsr0::output("Hello from Psr0 loaded class!");
    //Map loader
    TestLoadedByMap::test();
    $homeController = new HomeController();
    echo $homeController->indexAction()->getContent(), "\n";
}