-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* why do i do this * aagin * seting up api * api working and profiler api sorted
- Loading branch information
1 parent
03714a7
commit 396caa1
Showing
14 changed files
with
252 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
RewriteEngine On | ||
RewriteCond %{REQUEST_URI} !(\.png|\.jpg|\.webp|\.gif|\.jpeg|\.zip|\.css|\.svg|\.js|\.pdf|\.ttf)$ | ||
RewriteRule (.*) index.php [QSA,L] | ||
|
||
# Redirect /phntm_profiler to /vendor/bchubbweb/phntm/oneoff/profiler.php | ||
RewriteRule ^phntm_profiler$ /vendor/bchubbweb/phntm/oneoff/profiler.php [L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Pages\Api; | ||
|
||
use bchubbweb\phntm\Resources\Layout as LayoutTemplate; | ||
|
||
class Layout extends LayoutTemplate | ||
{ | ||
public function __construct() { | ||
|
||
$this->setContentType('application/json'); | ||
|
||
$this->setContent('<!-- content /-->'); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Pages\Api\Profiler; | ||
|
||
use bchubbweb\phntm\Resources\Page as PageTemplate; | ||
use bchubbweb\phntm\Phntm; | ||
|
||
class Page extends PageTemplate | ||
{ | ||
public function __construct() | ||
{ | ||
$this->setContent(Phntm::Redis()->get('phntm_profiling')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const onDOMContentLoaded = (init) => { | ||
if (['complete', 'interactive', 'loaded'].includes(document.readyState)) { | ||
init(); | ||
} else { | ||
document.addEventListener('DOMContentLoaded', init); | ||
} | ||
}; | ||
const findComments = function(el) { | ||
var arr = []; | ||
for(var i = 0; i < el.childNodes.length; i++) { | ||
var node = el.childNodes[i]; | ||
if(node.nodeType === 8) { | ||
arr.push(node); | ||
} else { | ||
arr.push.apply(arr, findComments(node)); | ||
} | ||
} | ||
return arr; | ||
}; | ||
|
||
const getEntries = async () => { | ||
entries = await fetch('/api/profiler'); | ||
return entries; | ||
}; | ||
|
||
const generateProfilerTable = (data) => { | ||
const dialog = document.createElement('dialog'); | ||
dialog.style.minWidth = '60vw'; | ||
dialog.open = true; | ||
dialog.id = 'profiler'; | ||
|
||
tableString = '<table style="width: 100%"><tbody>'; | ||
for (let i = 0; i < data.length -1; i++) { | ||
const entry = data[i]; | ||
const duration = data[i+1] ? data[i+1]['timestamp'] - entry['timestamp'] : 0; | ||
tableString += '<tr><td>' + entry['parent'] + '</td><td>' + entry['message'] + '</td><td>' + duration.toPrecision(8) + '</td></tr>'; | ||
} | ||
tableString += '<tr><td>' + data[data.length -1]['parent'] + '</td><td>' + data[data.length -1]['message'] + '</td><td>n/a</td></tr></tbody></table>'; | ||
|
||
dialog.innerHTML = tableString; | ||
return dialog; | ||
}; | ||
|
||
onDOMContentLoaded(() => { | ||
findComments(document).forEach((comment) => { | ||
if (comment.textContent === ' profiler-insert ') { | ||
getEntries().then((entries) => { | ||
entries.json().then((data) => { | ||
const dialog = generateProfilerTable(data); | ||
|
||
document.body.appendChild(dialog); | ||
}); | ||
}); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
require_once __DIR__ . '/../../../autoload.php'; | ||
|
||
use bchubbweb\phntm\Phntm; | ||
|
||
header('Content-Type: application/json'); | ||
|
||
echo Phntm::Redis()->get('phntm_profiling'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.