本文整理汇总了PHP中SplClassLoader类的典型用法代码示例。如果您正苦于以下问题:PHP SplClassLoader类的具体用法?PHP SplClassLoader怎么用?PHP SplClassLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SplClassLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_include_path
* 14 of the GNU General Public License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package phpBB
* @author Nils Adermann <naderman@phpbb.com>
* @copyright 2010 phpBB Ltd.
* @license http://www.gnu.org/licenses/gpl.txt
* GNU General Public License
* @version Release: @package_version@
*/
// set up include path
set_include_path(__DIR__ . '/lib/' . PATH_SEPARATOR . get_include_path() . PATH_SEPARATOR);
if (!defined('PHP_EXT')) {
define('PHP_EXT', strrchr(__FILE__, '.'));
}
require 'SplClassLoader' . PHP_EXT;
// phpBB's autoloader
$phpBBClassLoader = new SplClassLoader('phpBB');
$phpBBClassLoader->setFileExtension(PHP_EXT);
$phpBBClassLoader->register();
// symfony autoloader
$symfonyClassLoader = new SplClassLoader('Symfony', 'symfony/src/');
$symfonyClassLoader->setFileExtension(PHP_EXT);
$symfonyClassLoader->register();
示例2: akismetCheck
/**
* Run an Akismet check for spam
* @param array $comment Message data. Required keys:
* permalink - the permanent location of the entry the comment was submitted to
* comment_type - may be blank, comment, trackback, pingback, or a made up value like "registration"
* comment_author - name submitted with the comment
* comment_author_email - email address submitted with the comment
* comment_author_url - URL submitted with comment
* comment_content - the content that was submitted
* @return bool true if spam
*/
public function akismetCheck($comment)
{
$loader = new SplClassLoader('Rzeka', __DIR__ . '/vendor/');
$loader->register();
$connector = new Rzeka\Service\Akismet\Connector\Curl();
$akismet = new Rzeka\Service\Akismet($connector);
$api_key = $this->config['akismet_api_key'];
$site_url = Config::get('site_url');
if (!$akismet->keyCheck($api_key, $site_url)) {
Log::error('Invalid Akismet API key', 'raven');
return false;
}
return $akismet->check($comment);
}
示例3: UpdateStatus
public function UpdateStatus()
{
$contract = DataObject::get_one('Contract', 'ID = ' . $_GET['id'] . " and EchosignID = '" . $_GET['documentKey'] . "'");
$contract->Status = $_GET['status'];
$contract->write();
mail('patriciotarantino@gmail.com', 'Contract Update' . $contract->EchosignID, json_encode($_GET));
die;
$ESLoader = new SplClassLoader('EchoSign', realpath(__DIR__ . '/../../'));
$ESLoader->register();
$client = new SoapClient(EchoSign\API::getWSDL());
$api = new EchoSign\API($client, 'PGRUY64K6T664Z');
$data = $api->getDocumentInfo($contract->EchosignID);
mail('patriciotarantino@gmail.com', 'Contract Update' . $contract->EchosignID, json_encode($data));
}
示例4: __construct
public function __construct()
{
ini_set('display_errors', 1);
error_reporting(E_ALL);
require __DIR__ . '/lib/SplClassLoader.php';
$classLoader = new SplClassLoader('WebSocket', __DIR__ . '/lib');
$classLoader->register();
$this->server = new \WebSocket\Server('127.0.0.1', 7000, false);
// host,port,ssl
// server settings:
$this->server->setCheckOrigin(true);
$this->server->setAllowedOrigin('foo.lh');
$this->server->setMaxClients(100);
$this->server->setMaxConnectionsPerIp(20);
$this->server->setMaxRequestsPerMinute(1000);
$this->server->registerApplication('demo', \WebSocket\Application\DemoApplication::getInstance());
$this->server->run();
}
示例5: SplClassLoader
<?php
require_once 'Lib/Autoloader.php';
$autoloader = new SplClassLoader('FrontController');
$autoloader->register();
$request = \FrontController\HttpRequest::createFromGlobals();
$testRoute = new \FrontController\HttpRoute('/', 'IndexController', 'index');
$testRoute2 = new \FrontController\HttpRoute('/foo', 'IndexController', 'foo');
$router = new \FrontController\HttpRouter(array($testRoute, $testRoute2));
$dispatcher = new \FrontController\HttpDispatcher();
$front = new FrontController\Front($router, $dispatcher);
$front->run($request, new \FrontController\HttpResponse());
示例6: defined
*
* sysMonDash is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sysMonDash is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with sysMonDash. If not, see <http://www.gnu.org/licenses/>.
*
*/
defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo'));
define('XML_CONFIG_FILE', DIRECTORY_SEPARATOR . 'etc' . DIRECTORY_SEPARATOR . 'sysMonDash' . DIRECTORY_SEPARATOR . 'config.xml');
define('CONSTANTS_FILE', __DIR__ . DIRECTORY_SEPARATOR . 'constants.php');
define('MODEL_PATH', __DIR__ . DIRECTORY_SEPARATOR . 'SMD');
define('LOCALES_PATH', __DIR__ . DIRECTORY_SEPARATOR . 'locales');
define('CSS_PATH', __DIR__ . DIRECTORY_SEPARATOR . APP_ROOT . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'styles.css');
define('TPL_PATH', __DIR__ . DIRECTORY_SEPARATOR . 'tpl');
define('DEBUG', false);
// Empezar a calcular el tiempo y memoria utilizados
$time_start = microtime(true);
$memInit = memory_get_usage();
require CONSTANTS_FILE;
require 'SplClassLoader.php';
$ClassLoader = new SplClassLoader();
$ClassLoader->setFileExtension('.class.php');
$ClassLoader->register();
示例7: set_include_path
<?php
set_include_path(__DIR__ . PATH_SEPARATOR . __DIR__ . DIRECTORY_SEPARATOR . 'lib' . PATH_SEPARATOR . get_include_path());
include 'SplClassLoaderUser.php';
$v1 = new SplClassLoaderUser('vendor0');
$v1->register();
$v2 = new SplClassLoaderUser('vendor1');
$v2->register();
$v3 = new SplClassLoaderUser('vendor2');
$v3->register();
//$v4 = new SplClassLoaderUser('vendor3');
//$v4->register();
$g = new SplClassLoader();
$g->register();
include 'batch_instances.php';
echo 'done';
示例8: error_reporting
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
// show errors
error_reporting(E_ALL);
// lets stop the time
$start = microtime(true);
// enable autoloading of classes
require_once('../lib/MwbExporter/Core/SplClassLoader.php');
$classLoader = new SplClassLoader();
$classLoader->setIncludePath('../lib');
$classLoader->register();
// show a simple text box with the output
echo '<textarea cols="100" rows="50">';
$setup = array();
// create a formatter
$formatter = new \MwbExporter\Formatter\Doctrine2\Annotation\Loader($setup);
// parse the mwb file
$mwb = new \MwbExporter\Core\Workbench\Document('data/test.mwb', $formatter);
// show the export output of the mwb file
示例9: array
|
*/
require_once __DIR__ . '/vendor/Slim/Slim.php';
require_once __DIR__ . '/vendor/SplClassLoader.php';
\Slim\Slim::registerAutoloader();
/*
|--------------------------------------------------------------------------
| Vendor libraries
|-------------------------------------------------------------------------
|
| Load miscellaneous third-party dependencies.
|
*/
$packages = array('Buzz', 'Carbon', 'emberlabs', 'Intervention', 'Michelf', 'Netcarver', 'Stampie', 'Symfony', 'Whoops', 'Zeuxisoo', 'erusev', 'Propel');
foreach ($packages as $package) {
$loader = new SplClassLoader($package, __DIR__ . '/vendor/');
$loader->register();
}
require_once __DIR__ . '/vendor/PHPMailer/PHPMailerAutoload.php';
require_once __DIR__ . '/vendor/Spyc/Spyc.php';
/*
|--------------------------------------------------------------------------
| The Template Parser
|--------------------------------------------------------------------------
|
| Statamic uses a *highly* modified fork of the Lex parser, created by
| Dan Horrigan. Kudos Dan!
|
*/
require_once __DIR__ . '/vendor/Lex/Parser.php';
/*
示例10: ini_set
<?php
/**
* Spellchecker class
*
* @package jQuery Spellchecker (https://github.com/badsyntax/jquery-spellchecker)
* @author Richard Willis
* @copyright (c) Richard Willis
* @license https://github.com/badsyntax/jquery-spellchecker/blob/master/LICENSE-MIT
*/
ini_set('display_errors', 1);
require_once 'SplClassLoader.php';
$classLoader = new SplClassLoader('SpellChecker', 'SpellChecker');
$classLoader->setIncludePathLookup(true);
$classLoader->register();
new \SpellChecker\Request();
示例11: set_include_path
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
set_include_path(get_include_path() . PATH_SEPARATOR . realpath(__DIR__ . '/../src'));
require_once 'SplClassLoader.php';
$l = new SplClassLoader('MaxTsepkov');
$l->register();
use MaxTsepkov\Markdown\Text;
class BenchmarkTest extends PHPUnit_Framework_TestCase
{
const MD_SIZE = 1048576;
// 1M
protected static $_markdown;
protected static $_timings = array();
/**
* Generate a large markdown document.
*
*/
public static function setUpBeforeClass()
{
$charset = "\n\t";
示例12: prepareExchangedData
function prepareExchangedData($data, $type)
{
//Load AES
$aes = new SplClassLoader('Encryption\\Crypt', '../includes/libraries');
$aes->register();
if ($type == "encode") {
if (isset($_SESSION['settings']['encryptClientServer']) && $_SESSION['settings']['encryptClientServer'] == 0) {
return json_encode($data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
} else {
return Encryption\Crypt\aesctr::encrypt(json_encode($data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP), $_SESSION['key'], 256);
}
} elseif ($type == "decode") {
if (isset($_SESSION['settings']['encryptClientServer']) && $_SESSION['settings']['encryptClientServer'] == 0) {
return json_decode($data, true);
} else {
return json_decode(Encryption\Crypt\aesctr::decrypt($data, $_SESSION['key'], 256), true);
}
}
}
示例13: updateCacheTable
/**
* updateCacheTable()
*
* Update the CACHE table
*/
function updateCacheTable($action, $id = "")
{
global $db, $server, $user, $pass, $database, $pre, $port;
require_once $_SESSION['settings']['cpassman_dir'] . '/sources/SplClassLoader.php';
//Connect to DB
require_once $_SESSION['settings']['cpassman_dir'] . '/includes/libraries/Database/Meekrodb/db.class.php';
DB::$host = $server;
DB::$user = $user;
DB::$password = $pass;
DB::$dbName = $database;
DB::$port = $port;
DB::$error_handler = 'db_error_handler';
$link = mysqli_connect($server, $user, $pass, $database, $port);
//Load Tree
$tree = new SplClassLoader('Tree\\NestedTree', '../includes/libraries');
$tree->register();
$tree = new Tree\NestedTree\NestedTree($pre . 'nested_tree', 'id', 'parent_id', 'title');
// Rebuild full cache table
if ($action == "reload") {
// truncate table
DB::query("TRUNCATE TABLE " . $pre . "cache");
// reload date
$rows = DB::query("SELECT *\n FROM " . $pre . "items as i\n INNER JOIN " . $pre . "log_items as l ON (l.id_item = i.id)\n AND l.action = %s\n AND i.inactif = %i", 'at_creation', 0);
foreach ($rows as $record) {
// Get all TAGS
$tags = "";
$itemTags = DB::query("SELECT tag FROM " . $pre . "tags WHERE item_id=%i", $record['id']);
foreach ($itemTags as $itemTag) {
if (!empty($itemTag['tag'])) {
$tags .= $itemTag['tag'] . " ";
}
}
// form id_tree to full foldername
$folder = "";
$arbo = $tree->getPath($record['id_tree'], true);
foreach ($arbo as $elem) {
if ($elem->title == $_SESSION['user_id'] && $elem->nlevel == 1) {
$elem->title = $_SESSION['login'];
}
if (empty($folder)) {
$folder = stripslashes($elem->title);
} else {
$folder .= " » " . stripslashes($elem->title);
}
}
// store data
DB::insert($pre . "cache", array('id' => $record['id'], 'label' => $record['label'], 'description' => $record['description'], 'tags' => $tags, 'id_tree' => $record['id_tree'], 'perso' => $record['perso'], 'restricted_to' => $record['restricted_to'], 'login' => $record['login'] == null ? "" : $record['login'], 'folder' => $folder, 'author' => $record['id_user']));
}
// UPDATE an item
} elseif ($action == "update_value") {
// get new value from db
$data = DB::queryfirstrow("SELECT label, description, id_tree, perso, restricted_to, login\n FROM " . $pre . "items\n WHERE id=%i", $id);
// Get all TAGS
$tags = "";
$itemTags = DB::query("SELECT tag FROM " . $pre . "tags WHERE item_id=%i", $id);
foreach ($itemTags as $itemTag) {
if (!empty($itemTag['tag'])) {
$tags .= $itemTag['tag'] . " ";
}
}
// form id_tree to full foldername
$folder = "";
$arbo = $tree->getPath($data['id_tree'], true);
foreach ($arbo as $elem) {
if ($elem->title == $_SESSION['user_id'] && $elem->nlevel == 1) {
$elem->title = $_SESSION['login'];
}
if (empty($folder)) {
$folder = stripslashes($elem->title);
} else {
$folder .= " » " . stripslashes($elem->title);
}
}
// finaly update
DB::update($pre . "cache", array('label' => $data['label'], 'description' => $data['description'], 'tags' => $tags, 'id_tree' => $data['id_tree'], 'perso' => $data['perso'], 'restricted_to' => $data['restricted_to'], 'login' => $data['login'], 'folder' => $folder, 'author' => $_SESSION['user_id']), "id = %i", $id);
// ADD an item
} elseif ($action == "add_value") {
// get new value from db
$data = DB::queryFirstRow("SELECT i.label, i.description, i.id_tree as id_tree, i.perso, i.restricted_to, i.id, i.login\n FROM " . $pre . "items as i\n INNER JOIN " . $pre . "log_items as l ON (l.id_item = i.id)\n WHERE i.id = %i\n AND l.action = %s", $id, 'at_creation');
// Get all TAGS
$tags = "";
$itemTags = DB::query("SELECT tag FROM " . $pre . "tags WHERE item_id = %i", $id);
foreach ($itemTags as $itemTag) {
if (!empty($itemTag['tag'])) {
$tags .= $itemTag['tag'] . " ";
}
}
// form id_tree to full foldername
$folder = "";
$arbo = $tree->getPath($data['id_tree'], true);
foreach ($arbo as $elem) {
if ($elem->title == $_SESSION['user_id'] && $elem->nlevel == 1) {
$elem->title = $_SESSION['login'];
}
if (empty($folder)) {
//.........这里部分代码省略.........
示例14: SplClassLoader
* Licensed under the MIT license
*
*/
/*******************************
* General Set-up
*******************************/
// check to see if json_decode exists. might be disabled in installs of PHP 5.5
if (!function_exists("json_decode")) {
print "Please check that your version of PHP includes the JSON extension. It's required for Pattern Lab to run. Aborting.\n";
exit;
}
// auto-load classes
require __DIR__ . "/lib/SplClassLoader.php";
$loader = new SplClassLoader('PatternLab', __DIR__ . '/lib');
$loader->register();
$loader = new SplClassLoader('Mustache', __DIR__ . '/lib');
$loader->setNamespaceSeparator("_");
$loader->register();
/*******************************
* Console Set-up
*******************************/
$console = new PatternLab\Console();
// set-up the generate command and options
$console->setCommand("g", "generate", "Generate Pattern Lab", "The generate command generates an entire site a single time. By default it removes old content in public/, compiles the patterns and moves content from source/ into public/");
$console->setCommandOption("g", "p", "patternsonly", "Generate only the patterns. Does NOT clean public/.", "To generate only the patterns:");
$console->setCommandOption("g", "n", "nocache", "Set the cacheBuster value to 0.", "To turn off the cacheBuster:");
$console->setCommandOption("g", "c", "enablecss", "Generate CSS for each pattern. Resource intensive.", "To run and generate the CSS for each pattern:");
// set-up an alias for the generate command
$console->setCommand("b", "build", "Alias for the generate command", "Alias for the generate command. Please refer to it's help for full options.");
// set-up the watch command and options
$console->setCommand("w", "watch", "Watch for changes and regenerate", "The watch command builds Pattern Lab, watches for changes in source/ and regenerates Pattern Lab when there are any.");
示例15: loadExtensions
/**
* Cargar las clases de las extensiones de sysPass
*/
private static function loadExtensions()
{
// Utilizar un cargador de clases PSR-0
require EXTENSIONS_PATH . DIRECTORY_SEPARATOR . 'SplClassLoader.php';
$phpSecLoader = new \SplClassLoader('phpseclib', EXTENSIONS_PATH);
$phpSecLoader->register();
}