Skip to content

Commit

Permalink
Merge 1ade5b4 into de50187
Browse files Browse the repository at this point in the history
  • Loading branch information
sj-i committed Jun 10, 2021
2 parents de50187 + 1ade5b4 commit 80fdf94
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 5 deletions.
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
"require": {
"php": "^7.4|^8.0",
"ext-ffi": "*",
"ext-pcntl": "*",
"ext-filter": "*",
"ext-json": "*",
"ext-pcntl": "*",
"symfony/console": "^5.0",
"php-di/php-di": "^6.1",
"amphp/parallel": "^1.4",
"amphp/amp": "^2.4"
"amphp/amp": "^2.4",
"hassankhan/config": "^2.1"
},
"require-dev": {
"ext-posix": "*",
Expand Down
69 changes: 66 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* This file is part of the sj-i/php-profiler package.
*
* (c) sji <sji@sj-i.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

return [
'reader' => [
'collect_data' => [
'class' => true,
'function' => true,
'file' => true,
'line' => true,
'opcode' => false,
],
],
'output' => [
'format' => [
'template' => 'phpspy'
// 'template' => 'json_lines'
],
],
];
1 change: 1 addition & 0 deletions config/di.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use PhpProfiler\Lib\Process\MemoryReader\MemoryReaderInterface;
use PhpProfiler\Lib\Process\Search\ProcessSearcher;
use PhpProfiler\Lib\Process\Search\ProcessSearcherInterface;

use function DI\autowire;

return [
Expand Down
20 changes: 20 additions & 0 deletions resources/templates/json_lines.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/**
* This file is part of the sj-i/php-profiler package.
*
* (c) sji <sji@sj-i.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

/**
* @var string[] $traces
*/
?>
<?php foreach ($traces as $trace): ?>
<?= json_encode($trace, JSON_UNESCAPED_UNICODE), "\n" ?>
<?php endforeach ?>
30 changes: 30 additions & 0 deletions resources/templates/phpspy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* This file is part of the sj-i/php-profiler package.
*
* (c) sji <sji@sj-i.dev>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

/**
* @var array<int, array{
* class?: string,
* function: string,
* file: string,
* line: int,
* }> $traces
*/
?>
<?php foreach ($traces as $depth => $trace): ?>
<?php if (isset($trace['class'])): ?>
<?= $depth ?> <?= $trace['class'] . '::' ?><?= $trace['function'] ?> <?= $trace['file'] ?>:<?= $trace['line'] ?>
<?php else: ?>
<?= $depth ?> <?= $trace['function'] ?> <?= $trace['file'] ?>:<?= $trace['line'] ?>
<?php endif ?>
<?php endforeach ?>

0 comments on commit 80fdf94

Please sign in to comment.