本文整理汇总了PHP中Tracy\Debugger类的典型用法代码示例。如果您正苦于以下问题:PHP Debugger类的具体用法?PHP Debugger怎么用?PHP Debugger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Debugger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dumpHtml
/**
* Dump rendered Html element or code and intended output generated by tidy and optional also Html element structure
*
* @param Html|string $htmlElement Html element or string
* @param bool $onlyReturn output in string and don't send it to output?
* @param int $maxDepth for Debugger::Dump output - to see how is the Html element built
* @param bool $includePrettyPrint along javascript code for prettyPrint activation?
* @return string Html output
*/
function dumpHtml($htmlElement, $onlyReturn = false, $maxDepth = 0, $includePrettyPrint = false)
{
$maxDepthBackup = Debugger::$maxDepth;
$maxLenBackup = Debugger::$maxLen;
$showLocationBackup = Debugger::$showLocation;
Debugger::$maxDepth = $maxDepth;
Debugger::$maxLen = 200000;
Debugger::$showLocation = false;
// convert to string only once - important for Scaffolding Renderer output
$renderedElement = (string) $htmlElement;
$output = '<div class="rendered-element">' . $renderedElement . '</div>';
$output .= '<pre class="prettyprint linenums pre-scrollable">' . htmlspecialchars(tidyFormatString($renderedElement)) . '</pre>';
if ($includePrettyPrint) {
$output .= '<script>prettyPrint();</script>';
}
if ($maxDepth > 0 && $htmlElement instanceof \Latte\Runtime\Html) {
Debugger::dump($renderedElement);
Debugger::dump($htmlElement);
}
Debugger::$maxDepth = $maxDepthBackup;
Debugger::$maxLen = $maxLenBackup;
Debugger::$showLocation = $showLocationBackup;
if (!$onlyReturn) {
echo $output;
}
return $output;
}
示例2: pmd
/**
* LeonardoCA\Tools\ProcessMonitor detail dump
*
* @param string $msg
* @param null $data
* @param null $dataDescription
* @param int $maxDepth
* @return void
*/
function pmd($msg = 'Detail Info', $data = null, $dataDescription = null, $maxDepth = 2)
{
$backupDepth = Debugger::$maxDepth;
Debugger::$maxDepth = $maxDepth;
ProcessMonitor::dump("<em style='color:#339'>{$msg}</em>", $data, null, ProcessMonitor::SHOW_DETAIL, $dataDescription);
Debugger::$maxDepth = $backupDepth;
}
示例3: process
/**
* Default form handler
*/
public function process()
{
/** @var ArrayHash $values */
$values = $this->values;
try {
$this->onBeforeProcess($this, $values);
if (isset($values->id)) {
$this->onBeforeUpdate($this, $values);
$arr = (array) $values;
unset($arr['id']);
$row = $this->selection->wherePrimary($values->id)->fetch();
$row->update($arr);
$this->onAfterUpdate($row, $this, $values);
} else {
$this->onBeforeInsert($this, $values);
$row = $this->selection->insert($values);
$this->onAfterInsert($row, $this, $values);
}
$this->onAfterProcess($row, $this, $values);
} catch (\PDOException $e) {
$this->addError($e->getMessage());
dump($e);
Debugger::log($e);
}
}
示例4: renderDefault
public function renderDefault()
{
$this->template->anyVariable = 'any value';
// $dao = $this->articles;
$this->template->articles = $this->articles->getArticles()->findAll();
$posts = $this->EntityManager->getRepository(Posts::getClassName());
$this->template->posts = $posts->findAll();
$this->template->myparametr = $this->context->parameters['first_parametr'];
// $this->template->test = $this->doSomeRefactoring('Hello world from blog');
// $post = new Posts();
// $post->title = 'New title';
// $post->text = 'New text New textNew text';
// $post->created_at = new \Nette\Utils\DateTime;
//
//
// $this->EntityManager->persist($post);
// $this->EntityManager->flush();
// $dao = $this->EntityManager->getRepository(Posts::getClassName());
// $dao->setTitle('test');
// $dao->__call('set', ['title' => 'my title']);
// dump($dao->__isset('title'));
// $dao->__set('title', 'test');
try {
$this->checkNum(2);
\Tracy\Debugger::barDump('If you see this, the number is 1 or below');
} catch (Nette\Application\BadRequestException $e) {
Debugger::log('Message: ' . $e->getMessage());
var_dump($e->getMessage());
}
// finally {
// \Tracy\Debugger::barDump('Got here Finally');
// }
}
示例5: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
Debugger::timer();
$output->writeln('Running tests...');
$runner = new Runner();
$path = realpath($input->getArgument('path'));
if ($path) {
if (is_dir($path)) {
$runner->setTestsRoot($path . '/');
foreach (Finder::findFiles('*.php')->exclude('tester.php')->from($path) as $path => $fileInfo) {
$basePath = Helpers::stripExtension($path);
$runner->addTest($basePath);
}
} else {
$basePath = Helpers::stripExtension($path);
$runner->addTest($basePath);
}
} else {
if ($path = realpath($input->getArgument('path') . '.php')) {
$basePath = Helpers::stripExtension($path);
$runner->addTest($basePath);
} else {
$output->writeln("<error>The given path isn't valid</error>");
return 1;
}
}
$runner->setOutput($output);
$runner->runTests();
$output->writeln('Completed in ' . round(Debugger::timer(), 2) . ' seconds');
if ($runner->failed()) {
return 1;
} else {
return 0;
}
}
示例6: __init
public function __init($directory = NULL, $email = NULL, BlueScreen $blueScreen = NULL)
{
if (!$directory) {
$directory = __DIR__ . "/../log/";
}
if (getenv("MONDA_DEBUG")) {
if (array_key_exists(getenv("MONDA_DEBUG"), self::$levels)) {
self::$loglevel = self::$levels[getenv("MONDA_DEBUG")];
Debugger::$productionMode = false;
} else {
self::log("Unknown log level!\n", Debugger::ERROR);
}
} else {
if (Options::get("debug")) {
if (array_key_exists(Options::get("debug"), self::$levels)) {
self::$loglevel = self::$levels[Options::get("debug")];
Debugger::$productionMode = false;
} else {
self::log("Unknown log level!\n", Debugger::ERROR);
}
}
}
self::$wwwlogger = new \Tracy\Logger($directory, $email, $blueScreen);
if (PHP_SAPI == "cli") {
if (Options::get("logfile")) {
self::$logfd = fopen(Options::get("logfile"), "w");
} else {
self::$logfd = STDERR;
}
}
}
示例7: handleRequest
private function handleRequest(React\Http\Request $request, React\Http\Response $response)
{
try {
$container = $this->containerFactory->createContainer();
/** @var HttpRequestFactory $requestFactory */
$requestFactory = $container->getByType(HttpRequestFactory::class);
$requestFactory->setFakeHttpRequest($this->createNetteHttpRequest($request));
/** @var CliRouter $router */
$cliRouter = $container->getService('console.router');
$cliRouter->setIsCli(FALSE);
/** @var Nette\Application\Application $application */
$application = $container->getByType(Nette\Application\Application::class);
array_unshift($application->onError, function () {
throw new AbortException();
});
ob_start();
$application->run();
$responseBody = ob_get_contents();
ob_end_clean();
$response->writeHead(200, array('Content-Type' => 'text/html; charset=utf-8'));
$response->end($responseBody);
} catch (\Exception $e) {
Debugger::log($e, Debugger::EXCEPTION);
$response->writeHead(500, array('Content-Type' => 'text/plain'));
$response->end('Internal Server Error');
}
}
示例8: importDataToStagingTable
protected function importDataToStagingTable($stagingTableName, $columns, $sourceData)
{
if (!isset($sourceData['schemaName'])) {
throw new Exception('Invalid source data. schemaName must be set', Exception::INVALID_SOURCE_DATA);
}
if (!isset($sourceData['tableName'])) {
throw new Exception('Invalid source data. schemaName must be set', Exception::INVALID_SOURCE_DATA);
}
$sql = "INSERT INTO " . $this->nameWithSchemaEscaped($stagingTableName) . " (" . implode(', ', array_map(function ($column) {
return $this->quoteIdentifier($column);
}, $columns)) . ") ";
$sql .= "SELECT " . implode(',', array_map(function ($column) {
return $this->quoteIdentifier($column);
}, $columns)) . " FROM " . $this->nameWithSchemaEscaped($sourceData['tableName'], $sourceData['schemaName']);
try {
Debugger::timer('copyToStaging');
$this->connection->query($sql);
$rows = $this->connection->fetchAll(sprintf('SELECT COUNT(*) as "count" from %s.%s', $this->connection->quoteIdentifier($this->schemaName), $this->connection->quoteIdentifier($stagingTableName)));
$this->importedRowsCount += (int) $rows[0]['count'];
$this->addTimer('copyToStaging', Debugger::timer('copyToStaging'));
} catch (\Exception $e) {
// everything is user error
throw new Exception($e->getMessage(), Exception::UNKNOWN_ERROR, $e);
}
}
示例9: onBootstrap
/**
* {@inheritDoc}
*/
public function onBootstrap(EventInterface $event)
{
/**
* @var ModuleOptions $moduleOptions
*/
$moduleOptions = $event->getTarget()->getServiceManager()->get('LemoTracy\\Options\\ModuleOptions');
if (true === $moduleOptions->getEnabled()) {
if (null !== $moduleOptions->getMode()) {
Debugger::enable($moduleOptions->getMode());
}
if (null !== $moduleOptions->getLogDirectory()) {
Debugger::$logDirectory = $moduleOptions->getLogDirectory();
}
if (null !== $moduleOptions->getLogSeverity()) {
Debugger::$logSeverity = $moduleOptions->getLogSeverity();
}
if (null !== $moduleOptions->getMaxDepth()) {
Debugger::$maxDepth = $moduleOptions->getMaxDepth();
}
if (null !== $moduleOptions->getMaxLen()) {
Debugger::$maxLen = $moduleOptions->getMaxLen();
}
if (null !== $moduleOptions->getShowBar()) {
Debugger::$showBar = $moduleOptions->getShowBar();
}
if (null !== $moduleOptions->getStrict()) {
Debugger::$strictMode = $moduleOptions->getStrict();
}
}
}
示例10: importDataToStagingTable
protected function importDataToStagingTable($stagingTempTableName, $columns, $sourceData, array $options = [])
{
if (!isset($sourceData['schemaName'])) {
throw new Exception('Invalid source data. schemaName must be set', Exception::INVALID_SOURCE_DATA);
}
if (!isset($sourceData['tableName'])) {
throw new Exception('Invalid source data. schemaName must be set', Exception::INVALID_SOURCE_DATA);
}
$sourceColumnTypes = $this->describeTable(strtolower($sourceData['tableName']), strtolower($sourceData['schemaName']));
$sql = "INSERT INTO " . $this->tableNameEscaped($stagingTempTableName) . " (" . implode(', ', array_map(function ($column) {
return $this->quoteIdentifier($column);
}, $columns)) . ") ";
$sql .= "SELECT " . implode(',', array_map(function ($column) use($sourceColumnTypes) {
if ($sourceColumnTypes[$column]['DATA_TYPE'] === 'bool') {
return sprintf('DECODE(%s, true, 1, 0) ', $this->quoteIdentifier($column));
} else {
return "COALESCE(CAST({$this->quoteIdentifier($column)} as varchar), '') ";
}
}, $columns)) . " FROM " . $this->nameWithSchemaEscaped($sourceData['tableName'], $sourceData['schemaName']);
try {
Debugger::timer('copyToStaging');
$this->query($sql);
$this->addTimer('copyToStaging', Debugger::timer('copyToStaging'));
} catch (\Exception $e) {
if (strpos($e->getMessage(), 'Datatype mismatch') !== false) {
throw new Exception($e->getMessage(), Exception::DATA_TYPE_MISMATCH, $e);
}
// everything is user error
throw new Exception($e->getMessage(), Exception::UNKNOWN_ERROR, $e);
}
}
示例11: formSucceeded
/**
* Callback for ForgottenPasswordForm onSuccess event.
* @param Form $form
* @param ArrayHash $values
*/
public function formSucceeded(Form $form, $values)
{
$user = $this->userManager->findByEmail($values->email);
if (!$user) {
$form->addError('No user with given email found');
return;
}
$password = Nette\Utils\Random::generate(10);
$this->userManager->setNewPassword($user->id, $password);
try {
// !!! Never send passwords through email !!!
// This is only for demonstration purposes of Notejam.
// Ideally, you can create a unique link where user can change his password
// himself for limited amount of time, and then send the link.
$mail = new Nette\Mail\Message();
$mail->setFrom('noreply@notejamapp.com', 'Notejamapp');
$mail->addTo($user->email);
$mail->setSubject('New notejam password');
$mail->setBody(sprintf('Your new password: %s', $password));
$this->mailer->send($mail);
} catch (Nette\Mail\SendException $e) {
Debugger::log($e, Debugger::EXCEPTION);
$form->addError('Could not send email with new password');
}
}
示例12: register
public static function register(Cron $cron, Request $request)
{
$bar = Debugger::getBar();
$panel = new static($cron, $request);
$bar->addPanel($panel);
return $panel;
}
示例13: createGuzzleClient
/**
* @param $tempDir
* @param array $guzzleConfig
* @return \GuzzleHttp\Client
* @throws \Matyx\Guzzlette\GuzzletteException
*/
public static function createGuzzleClient($tempDir, $guzzleConfig = [])
{
if (isset(static::$client)) {
return static::$client;
}
if (Tracy\Debugger::isEnabled()) {
$handler = NULL;
if (isset($guzzleConfig['handler'])) {
$handler = $guzzleConfig['handler'];
if (!$handler instanceof GuzzleHttp\HandlerStack) {
throw new GuzzletteException("Handler must be instance of " . GuzzleHttp\HandlerStack::class);
}
} else {
$handler = GuzzleHttp\HandlerStack::create();
}
$requestStack = new RequestStack();
Tracy\Debugger::getBar()->addPanel(new TracyPanel($tempDir, $requestStack));
$handler->push(function (callable $handler) use($requestStack) {
return function ($request, array $options) use($handler, $requestStack) {
Tracy\Debugger::timer();
$guzzletteRequest = new Request();
$guzzletteRequest->request = $request;
return $handler($request, $options)->then(function ($response) use($requestStack, $guzzletteRequest) {
$guzzletteRequest->time = Tracy\Debugger::timer();
$guzzletteRequest->response = $response;
$requestStack->addRequest($guzzletteRequest);
return $response;
});
};
});
$guzzleConfig['handler'] = $handler;
}
static::$client = new GuzzleHttp\Client($guzzleConfig);
return static::$client;
}
示例14: actionDefault
/**
* Provide auto merge
*/
public function actionDefault()
{
$payload = $this->httpRequest->getRawBody();
if (!$payload) {
Debugger::log('No payload data', Debugger::ERROR);
$this->terminate();
}
$data = json_decode($payload, true);
if (!$data) {
Debugger::log('json_decode error', Debugger::ERROR);
$this->terminate();
}
if ($data['object_kind'] != 'note') {
Debugger::log('Only notes object kind processing now. *' . $data['object_kind'] . '* given', Debugger::ERROR);
$this->terminate();
}
$projectId = isset($data['merge_request']['source_project_id']) ? $data['merge_request']['source_project_id'] : false;
$mergeRequestId = isset($data['merge_request']['id']) ? $data['merge_request']['id'] : false;
if (!$projectId || !$mergeRequestId) {
Debugger::log('projectId or mergeRequestId missing', Debugger::ERROR);
$this->terminate();
}
$project = $this->projectRepository->findByGitlabId($projectId);
if (!$project) {
Debugger::log('Project ' . $projectId . ' is not allowed to auto merge', Debugger::ERROR);
$this->terminate();
}
$mr = $this->gitlabClient->api('mr')->show($projectId, $mergeRequestId);
$mergeRequest = $this->mergeRequestBuilder->create($mr, $data);
if ($mergeRequest->canBeAutoMerged($project->positive_votes)) {
$this->gitlabClient->api('mr')->merge($projectId, $mergeRequestId, 'Auto merged');
}
}
示例15: __construct
public function __construct($slackUrl, IMessageFactory $messageFactory, $timeout)
{
parent::__construct(Debugger::$logDirectory, Debugger::$email, Debugger::getBlueScreen());
$this->slackUrl = $slackUrl;
$this->messageFactory = $messageFactory;
$this->timeout = $timeout;
}