当前位置: 首页>>代码示例>>PHP>>正文


PHP Nette\Debug类代码示例

本文整理汇总了PHP中Nette\Debug的典型用法代码示例。如果您正苦于以下问题:PHP Debug类的具体用法?PHP Debug怎么用?PHP Debug使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Debug类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __toString

 /**
  * Converts link to URL.
  * @return string
  */
 public function __toString()
 {
     try {
         return $this->component->link($this->destination, $this->params);
     } catch (\Exception $e) {
         Nette\Debug::toStringException($e);
     }
 }
开发者ID:JanTvrdik,项目名称:nette,代码行数:12,代码来源:Link.php

示例2: __construct

 public function __construct($host = 'localhost', $port = 11211, $prefix = '', Nette\Context $context = NULL)
 {
     if (!self::isAvailable()) {
         throw new \NotSupportedException("PHP extension 'memcache' is not loaded.");
     }
     $this->prefix = $prefix;
     $this->context = $context;
     $this->memcache = new \Memcache();
     Nette\Debug::tryError();
     $this->memcache->connect($host, $port);
     if (Nette\Debug::catchError($msg)) {
         throw new \InvalidStateException($msg);
     }
 }
开发者ID:JPalounek,项目名称:IconStore,代码行数:14,代码来源:MemcachedStorage.php

示例3: send

 /**
  * Sends e-mail.
  * @param  Mail
  * @return void
  */
 public function send(Mail $mail)
 {
     $tmp = clone $mail;
     $tmp->setHeader('Subject', NULL);
     $tmp->setHeader('To', NULL);
     $parts = explode(Mail::EOL . Mail::EOL, $tmp->generateMessage(), 2);
     Nette\Debug::tryError();
     $res = mail(str_replace(Mail::EOL, PHP_EOL, $mail->getEncodedHeader('To')), str_replace(Mail::EOL, PHP_EOL, $mail->getEncodedHeader('Subject')), str_replace(Mail::EOL, PHP_EOL, $parts[1]), str_replace(Mail::EOL, PHP_EOL, $parts[0]));
     if (Nette\Debug::catchError($msg)) {
         throw new \InvalidStateException($msg);
     } elseif (!$res) {
         throw new \InvalidStateException('Unable to send email.');
     }
 }
开发者ID:JPalounek,项目名称:IconStore,代码行数:19,代码来源:SendmailMailer.php

示例4: __construct

 public function __construct($host = 'localhost', $port = 11211, $prefix = '', ICacheJournal $journal = NULL)
 {
     if (!self::isAvailable()) {
         throw new \NotSupportedException("PHP extension 'memcache' is not loaded.");
     }
     $this->prefix = $prefix;
     $this->journal = $journal;
     $this->memcache = new \Memcache();
     Nette\Debug::tryError();
     $this->memcache->connect($host, $port);
     if (Nette\Debug::catchError($e)) {
         throw new \InvalidStateException($e->getMessage());
     }
 }
开发者ID:JanTvrdik,项目名称:nette,代码行数:14,代码来源:MemcachedStorage.php

示例5: renderDefault

	/**
	 * @param  Exception
	 * @return void
	 */
	public function renderDefault($exception)
	{
		if ($this->isAjax()) { // AJAX request? Just note this error in payload.
			$this->payload->error = TRUE;
			$this->terminate();

		} elseif ($exception instanceof BadRequestException) {
			$code = $exception->getCode();
			$this->setView(in_array($code, array(403, 404, 405, 410, 500)) ? $code : '4xx'); // load template 403.latte or 404.latte or ... 4xx.latte

		} else {
			$this->setView('500'); // load template 500.latte
			Debug::log($exception, Debug::ERROR); // and log exception
		}
	}
开发者ID:newPOPE,项目名称:screencast,代码行数:19,代码来源:ErrorPresenter.php

示例6: __toString

 /**
  * Renders template to string.
  * @param  bool  can throw exceptions? (hidden parameter)
  * @return string
  */
 public function __toString()
 {
     ob_start();
     try {
         $this->render();
         return ob_get_clean();
     } catch (\Exception $e) {
         ob_end_clean();
         if (func_num_args() && func_get_arg(0)) {
             throw $e;
         } else {
             Nette\Debug::toStringException($e);
         }
     }
 }
开发者ID:nella,项目名称:ActiveMapper,代码行数:20,代码来源:BaseTemplate.php

示例7: encode

	/**
	 * Returns the JSON representation of a value.
	 * @param  mixed
	 * @return string
	 */
	public static function encode($value)
	{
		Debug::tryError();
		if (function_exists('ini_set')) {
			$old = ini_set('display_errors', 0); // needed to receive 'Invalid UTF-8 sequence' error
			$json = json_encode($value);
			ini_set('display_errors', $old);
		} else {
			$json = json_encode($value);
		}
		if (Debug::catchError($e)) { // needed to receive 'recursion detected' error
			throw new JsonException($e->getMessage());
		}
		return $json;
	}
开发者ID:newPOPE,项目名称:screencast,代码行数:20,代码来源:Json.php

示例8: renderDefault

 /**
  * @param  Exception
  * @return void
  */
 public function renderDefault($exception)
 {
     if ($this->isAjax()) {
         // AJAX request? Just note this error in payload.
         $this->payload->error = TRUE;
         $this->terminate();
     } elseif ($exception instanceof BadRequestException) {
         $this->setView('404');
         // load template 404.phtml
     } else {
         $this->setView('500');
         // load template 500.phtml
         Debug::processException($exception);
         // and handle error by Nette\Debug
     }
 }
开发者ID:jakubkulhan,项目名称:nette,代码行数:20,代码来源:ErrorPresenter.php

示例9: __construct

 public function __construct($dsn, $username = NULL, $password = NULL, array $options = NULL)
 {
     parent::__construct($dsn, $username, $password, $options);
     $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('Nette\\Database\\Statement', array($this)));
     $class = 'Nette\\Database\\Drivers\\Pdo' . $this->getAttribute(PDO::ATTR_DRIVER_NAME) . 'Driver';
     if (class_exists($class)) {
         $this->driver = new $class($this, (array) $options);
     }
     $this->preprocessor = new SqlPreprocessor($this);
     $this->databaseReflection = new Nette\Database\Reflection\DatabaseReflection();
     // TODO
     if (!Nette\Debug::$productionMode) {
         Nette\Debug::addPanel($panel = new DatabasePanel($dsn));
         $this->onQuery[] = callback($panel, 'logQuery');
     }
 }
开发者ID:JanTvrdik,项目名称:nette,代码行数:17,代码来源:Connection.php

示例10: processRequest

	/**
	 * Processes request.
	 *
	 * @author   Jan Tvrdík
	 * @param    PresenterRequest
	 * @return   void
	 * @throws   Nette\Applicationy\AbortException|\InvalidStateException
	 */
	public function processRequest(PresenterRequest $request)
	{
		$params = $request->getParams();
		$exception = & $params['exception'];
		if (!isset($exception)) {
			throw new \InvalidStateException('Missing required parameter - exception.');
		}

		if ($exception instanceof BadRequestException) {
			$code = $exception->getCode();
			$name = in_array($code, array(403, 404, 405, 410, 500)) ? $code : '4xx';

		} else {
			Debug::log($exception, Debug::ERROR);
			$name = '500';
		}

		$this->page = '@errors/' . $name;
		$this->sendTemplate();
	}
开发者ID:JanTvrdik,项目名称:StaticWeb,代码行数:28,代码来源:ErrorPresenter.php

示例11: catchPregError

	/** @internal */
	public static function catchPregError($pattern)
	{
		if (Debug::catchError($e)) { // compile error
			throw new RegexpException($e->getMessage() . " in pattern: $pattern");

		} elseif (preg_last_error()) { // run-time error
			static $messages = array(
				PREG_INTERNAL_ERROR => 'Internal error',
				PREG_BACKTRACK_LIMIT_ERROR => 'Backtrack limit was exhausted',
				PREG_RECURSION_LIMIT_ERROR => 'Recursion limit was exhausted',
				PREG_BAD_UTF8_ERROR => 'Malformed UTF-8 data',
				5 => 'Offset didn\'t correspond to the begin of a valid UTF-8 code point', // PREG_BAD_UTF8_OFFSET_ERROR
			);
			$code = preg_last_error();
			throw new RegexpException((isset($messages[$code]) ? $messages[$code] : 'Unknown error') . " (pattern: $pattern)", $code);
		}
	}
开发者ID:JanTvrdik,项目名称:StaticWeb,代码行数:18,代码来源:String.php

示例12:

<?php

namespace ActiveMapperTests;

require_once __DIR__ . "/../libs/Nette/loader.php";
\Nette\Debug::enable(\Nette\Debug::DEVELOPMENT);
\Nette\Environment::setVariable("tempDir", __DIR__ . "/_temp");
$loader = new \Nette\Loaders\RobotLoader();
$loader->addDirectory(__DIR__ . "/../libs");
$loader->addDirectory(__DIR__ . "/../ActiveMapper");
$loader->addDirectory(__DIR__ . "/../examples/Models");
$loader->register();
\dibi::connect(array('driver' => "sqlite3", 'database' => ":memory:", 'formatDateTime' => "'Y-m-d H:i:s'", 'lazy' => TRUE, 'profiler' => TRUE));
\dibi::loadFile(__DIR__ . "/db.structure.sql");
\dibi::loadFile(__DIR__ . "/db.data.sql");
开发者ID:nella,项目名称:ActiveMapper,代码行数:15,代码来源:bootstrap.php

示例13: grep

 /**
  * Return array entries that match the pattern.
  * @param  array
  * @param  string
  * @param  int
  * @return array
  */
 public static function grep(array $arr, $pattern, $flags = 0)
 {
     Debug::tryError();
     $res = preg_grep($pattern, $arr, $flags);
     String::catchPregError($pattern);
     return $res;
 }
开发者ID:JanTvrdik,项目名称:nette,代码行数:14,代码来源:ArrayTools.php

示例14: load

 /**
  * Reads configuration from INI file.
  * @param  string  file name
  * @param  string  section to load
  * @return array
  * @throws \InvalidStateException
  */
 public static function load($file, $section = NULL)
 {
     if (!is_file($file) || !is_readable($file)) {
         throw new \FileNotFoundException("File '{$file}' is missing or is not readable.");
     }
     Nette\Debug::tryError();
     $ini = parse_ini_file($file, TRUE);
     if (Nette\Debug::catchError($e)) {
         throw $e;
     }
     $separator = trim(self::$sectionSeparator);
     $data = array();
     foreach ($ini as $secName => $secData) {
         // is section?
         if (is_array($secData)) {
             if (substr($secName, -1) === self::$rawSection) {
                 $secName = substr($secName, 0, -1);
             } elseif (self::$keySeparator) {
                 // process key separators (key1> key2> key3)
                 $tmp = array();
                 foreach ($secData as $key => $val) {
                     $cursor =& $tmp;
                     foreach (explode(self::$keySeparator, $key) as $part) {
                         if (!isset($cursor[$part]) || is_array($cursor[$part])) {
                             $cursor =& $cursor[$part];
                         } else {
                             throw new \InvalidStateException("Invalid key '{$key}' in section [{$secName}] in '{$file}'.");
                         }
                     }
                     $cursor = $val;
                 }
                 $secData = $tmp;
             }
             // process extends sections like [staging < production] (with special support for separator ':')
             $parts = $separator ? explode($separator, strtr($secName, ':', $separator)) : array($secName);
             if (count($parts) > 1) {
                 $parent = trim($parts[1]);
                 $cursor =& $data;
                 foreach (self::$keySeparator ? explode(self::$keySeparator, $parent) : array($parent) as $part) {
                     if (isset($cursor[$part]) && is_array($cursor[$part])) {
                         $cursor =& $cursor[$part];
                     } else {
                         throw new \InvalidStateException("Missing parent section [{$parent}] in '{$file}'.");
                     }
                 }
                 $secData = Nette\ArrayTools::mergeTree($secData, $cursor);
             }
             $secName = trim($parts[0]);
             if ($secName === '') {
                 throw new \InvalidStateException("Invalid empty section name in '{$file}'.");
             }
         }
         if (self::$keySeparator) {
             $cursor =& $data;
             foreach (explode(self::$keySeparator, $secName) as $part) {
                 if (!isset($cursor[$part]) || is_array($cursor[$part])) {
                     $cursor =& $cursor[$part];
                 } else {
                     throw new \InvalidStateException("Invalid section [{$secName}] in '{$file}'.");
                 }
             }
         } else {
             $cursor =& $data[$secName];
         }
         if (is_array($secData) && is_array($cursor)) {
             $secData = Nette\ArrayTools::mergeTree($secData, $cursor);
         }
         $cursor = $secData;
     }
     if ($section === NULL) {
         return $data;
     } elseif (!isset($data[$section]) || !is_array($data[$section])) {
         throw new \InvalidStateException("There is not section [{$section}] in '{$file}'.");
     } else {
         return $data[$section];
     }
 }
开发者ID:Balvan,项目名称:nette,代码行数:84,代码来源:ConfigAdapterIni.php

示例15: date

namespace App;

require_once __DIR__ . "/bootstrap.php";
use Nette\Debug, Nette\Framework, dibi;
Debug::timer('benchmark');
$memory = memory_get_peak_usage();
echoBeginHtml();
/********************************************************************************************************************************/
// Setum entity manager
$em = new \ActiveMapper\Manager(\dibi::getConnection());
echo "<h1>All authors</h1>";
// Get all authors
$authors = $em->findAll('App\\Models\\Author');
foreach ($authors as $author) {
    Debug::dump($author->name);
    Debug::dump($author->blog->name);
}
echo "<h1>Author by ID #3</h1>";
// Get author by id
$author = $em->find('App\\Models\\Author', 3);
Debug::dump($author->name);
Debug::dump($author->blog->name);
/********************************************************************************************************************************/
// Benchmark data
Debug::barDump(Framework::NAME . " " . Framework::VERSION . " " . Framework::REVISION);
Debug::barDump("dibi " . dibi::VERSION . " " . dibi::REVISION);
Debug::barDump($mappingTime = number_format(Debug::timer('benchmark') * 1000, 1, '.', ' ') . "ms", "Mapping Time");
Debug::barDump($mappingMemory = number_format((memory_get_peak_usage() - $memory) / 1000, 1, '.', ' ') . "kB", "Mapping Memory");
echo '<p><a href="http://github.com/Vrtak-CZ/ActiveMapper/blob/master/examples/index.php" target="_blank">' . 'Show code on GitHub</a> - <a href="http://am.vrtak-cz.net/coverage">Show coverage</a></p>';
$benchMarkData = "mapping time: {$mappingTime} mapping memory: {$mappingMemory} " . "total time: " . number_format((microtime(TRUE) - Debug::$time) * 1000, 1, '.', ' ') . "ms " . "total memory: " . number_format(memory_get_peak_usage() / 1000, 1, '.', ' ') . "kB";
file_put_contents(__DIR__ . "/benchmark.log", date("r") . " # " . $benchMarkData . PHP_EOL, FILE_APPEND);
开发者ID:nella,项目名称:ActiveMapper,代码行数:31,代码来源:index.php


注:本文中的Nette\Debug类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。