daylerees / anbu Goto Github PK
View Code? Open in Web Editor NEWAnbu profiler for the Laravel PHP Framework.
Anbu profiler for the Laravel PHP Framework.
I wanted to try Anbu, but after updating composer and setting the service provider im getting exception 'Illuminate\Container\BindingResolutionException' with message 'Target [Anbu\Repositories\Repository] is not instantiable.' after calling ad('foo'). It seems that the package isn't really loaded because php artisan anbu:clear gives "There are no commands defined in the "anbu" namespace.".
What went wrong? Any idea?
I had a need to disable the Anbu for a particular request while testing and I was presented with the following error
Undefined index: disable
…/vendor/daylerees/anbu/src/Profiler.php:338
I figured it was an issue in the Facade class itself so I was able to fix it with the following.
<?php
namespace Anbu\Facades;
use App;
class Anbu
{
/**
* Proxy static method calls to module instances.
*
* @param string $method
* @param mixed $args
* @return mixed
*/
public static function __callStatic($method, $args)
{
// Resolve profiler from container.
$profiler = App::make('Anbu\\Profiler');
if($method == 'disable')
{
return $profiler->disable();
}
if($method == 'hide')
{
return $profiler->hide();
}
// Return the module instance by method name.
return $profiler->getModule($method);
}
}
Im sure that you may have a better solution to this issue than this one but I just wanted to give you a heads up.
Hello.
When i enabled Anbu the page request delayed 50 seconds approximately.
But when i disabled Anbu delayed less than 1 second approximately.
Note: The "storage" field on "anbu" table weighs about 10 kb approximately.
Hi and thanks for this nice profiler.
After uploading a file I get the exception below. I am not sure if I should just exclude anbu for this request or if this is a bug.
{"error":{"type":"Exception","message":"Serialization of 'Symfony\Component\HttpFoundation\File\UploadedFile' is not allowed","file":"/home/vagrant/.../vendor/daylerees/anbu/src/Profiler.php","line":234}}
Thanks!
When serving assets through CodeSleeve/asset-pipeline, the profiler also runs for each asset served. Hence the HTML for the Anbu link is prepended to each of those files causing them to be unusable.
In the Profiler
in the afterHook
method changing this check
if (!strstr($type, 'json')) {
to
if (strstr($type, 'text/html')) {
resolved the issue for me.
Mind you that the profiler will still run for each asset served, so your page might load slowly.
Since this is a work in progress and @daylerees requested it, I havent created a pull request for this.
SQLSTATE[08S01]: Communication link failure: 1153 Got a packet bigger than 'max_allowed_packet' bytes (SQL: insert into anbu
(uri
, time
, storage
, updated_at
, created_at
) values (GET user/logout, 1.3028910160065, YToxMDp7czo5OiJkYXNoYm9hcmQiO2E6Mzp7czo0OiJkYXRhIjthOjA6e31zOjY6Imdsb2JhbCI7YToxOntzOjc6InZlcnNpb24iO3M6NToiNC4yLjkiO31zOjU.......
Any plans Dayle? 😄
Now, when I am on, for example, "Queries tab", and in background something is going on. I want to go to the latest "queries" I need to use "Back to latest" button, which doesn't respect the tab you are on.
Would be nice just to have this button "remember" current "tab".
We've been looking at using Anbu, but unfortunately the output is messing up our icons. We've found that this is caused by Anbu placing its button HTML before any other HTML, including the head
and body
tags.
Is there a way that we can manually place the button, without it blindly placing it somewhere?
It took me a bit of time to figure this out, but finally tracked it down.
When Anbu is active, Behat tests get hammered as it shows a message 'redirecting to...' whenever a redirect occurs. So, it falls my checks for 'expect to see'
So, in addition to only having enabled when 'debug' is true, how about disabling when 'testing' is true?
For better or for worse, default blade syntax for HTML in L5 is now {!! $var !!}
.
Local workaround:
{{ $child }}
to {!! $child !!}
{{ $debug }}
to {!! $debug !!}
{{ $history->links() }}
to {!! $history->links() !!}
{{ $info }}
to {!! $info !!}
{{ $widget->view }}
to {!! $widget->view !!}
Alternatively, you theoretically should be able to bind the old escaped echo delimiters to Blade using \Blade::setEscapedContentTags('{{', '}}')
, but I'm having trouble getting that to work (tried it at the end of the BaseController constructor).
Great work! Can't wait to see this evolve over time!
Is there any chance you could add support for displaying profiler button when in debug mode ONLY? I have hacked it together, but since this is still a fluid project (with many more updates coming) figured it would be better to have you add it to package.
Maybe I am doing something wrong?
In my case Anbu html code is outputing before even < html > tag -- i.e before any ouput from templates.
Which totally screws all session handling.
I wasted 4 hours trying to understand why auth suddenly stopped working - the answer was due to output before headers, cookies were not properly set, and new session was regenerated every page reload.
UPD: Code outputted is from view 'anbu::button'. It is echoed in anbu/src/Profiler.php @213
Maybe this hook 'executeAfterHook' is not hooked up properly?
public function executeAfterHook($request, $response)
{
// If the profiler is disabled...
if (!$this->enabled) {
// Exit, we don't want to log requests to the profiler.
return;
}
// Execute the after hook for each module.
$this->executeModuleAfterHooks($request, $response);
// Store the module and return it.
$storage = $this->storeModuleData();
// Get content type header.
$type = $response->headers->get('Content-Type');
// Check for JSON in the header.
if (strstr($type, 'text/html') && $this->display) {
// Get the view component.
$view = $this->app->make('view');
// Append button to response.
echo $view->make('anbu::button', compact('storage')); # <============
}
}
Please add further information in the readme how to install the package since there's no Composer package or where to place the code instructions.
It would also be good to see how I can only apply this anbu profiler to a dev environment, maybe that's already working I don't know since I can't test it. :)
Thanks in advice!
Hi and thanks for this nice profiler
the response did not send the header:
I think because the Anbu\Profiler::executeAfterHook had sended a view before Symfony\Component\HttpFoundation\Response call the sendHeaders()
and the view's content is too much to make the buffer overflows (my php.ini set: output_buffering=4096), that the headers_sent() will return true
so Symfony\Component\HttpFoundation\Responsethe::sendHeaders() is not working
Thanks!
Here: https://github.com/daylerees/anbu/blob/master/src/Modules/QueryLogger/QueryLogger.php#L42
Not sure how you'd like to handle these as the list is rather large (http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html)!
I'll PR if you're happy for them all to be included?
/**
* SQL keywords to highlight.
*
* @var array
*/
protected $keywords = ['add', 'all', 'alter', 'analyze', 'and', 'as', 'asc', 'asensitive', 'before', 'between', 'bigint', 'binary', 'blob', 'both', 'by', 'call', 'cascade', 'case', 'change', 'char', 'character', 'check', 'collate', 'column', 'condition', 'constraint', 'continue', 'convert', 'create', 'cross', 'current_date', 'current_time', 'current_timestamp', 'current_user', 'cursor', 'database', 'databases', 'day_hour', 'day_microsecond', 'day_minute', 'day_second', 'dec', 'decimal', 'declare', 'default', 'delayed', 'delete', 'desc', 'describe', 'deterministic', 'distinct', 'distinctrow', 'div', 'double', 'drop', 'dual', 'each', 'else', 'elseif', 'enclosed', 'escaped', 'exists', 'exit', 'explain', 'false', 'fetch', 'float', 'float4', 'float8', 'for', 'force', 'foreign', 'from', 'fulltext', 'grant', 'group', 'having', 'high_priority', 'hour_microsecond', 'hour_minute', 'hour_second', 'if', 'ignore', 'in', 'index', 'infile', 'inner', 'inout', 'insensitive', 'insert', 'int', 'int1', 'int2', 'int3', 'int4', 'int8', 'integer', 'interval', 'into', 'is', 'iterate', 'join', 'key', 'keys', 'kill', 'leading', 'leave', 'left', 'like', 'limit', 'lines', 'load', 'localtime', 'localtimestamp', 'lock', 'long', 'longblob', 'longtext', 'loop', 'low_priority', 'match', 'mediumblob', 'mediumint', 'mediumtext', 'middleint', 'minute_microsecond', 'minute_second', 'mod', 'modifies', 'natural', 'not', 'no_write_to_binlog', 'null', 'numeric', 'on', 'optimize', 'option', 'optionally', 'or', 'order', 'out', 'outer', 'outfile', 'precision', 'primary', 'procedure', 'purge', 'read', 'reads', 'real', 'references', 'regexp', 'release', 'rename', 'repeat', 'replace', 'require', 'restrict', 'return', 'revoke', 'right', 'rlike', 'schema', 'schemas', 'second_microsecond', 'select', 'sensitive', 'separator', 'set', 'show', 'smallint', 'soname', 'spatial', 'specific', 'sql', 'sqlexception', 'sqlstate', 'sqlwarning', 'sql_big_result', 'sql_calc_found_rows', 'sql_small_result', 'ssl starting', 'straight_join', 'table', 'terminated', 'then', 'tinyblob', 'tinyint', 'tinytext', 'to', 'trailing', 'trigger true', 'undo', 'union', 'unique', 'unlock', 'unsigned', 'update', 'usage', 'use using', 'utc_date', 'utc_time', 'utc_timestamp', 'values', 'varbinary', 'varchar', 'varcharacter', 'varying when', 'where', 'while', 'with', 'write', 'xor year_month', 'zerofill', 'asensitive', 'call', 'condition', 'connection', 'continue', 'cursor', 'declare deterministic', 'each', 'elseif', 'exit', 'fetch', 'goto', 'inout', 'insensitive', 'iterate', 'label', 'leave', 'loop', 'modifies', 'out', 'reads', 'release repeat', 'return', 'schema', 'schemas', 'sensitive', 'specific', 'sql', 'sqlexception', 'sqlstate', 'sqlwarning', 'trigger undo', 'upgrade', 'while'];
Is there any reason why the when data is serialized it's done in a real basic index-like fashion? E.g. for the routing table:
// Add a new route to the data array.
$this->data['routes'][] = [
$route->getMethods(), // HTTP Verb
$this->highlightParams($route->getPath()), // URI
$route->getActionName() // Action
];
}
Then when outputing in the view:
<tr>
<td><span class="method-tag method-tag-{{ strtolower($current[0]) }}">{{ $current[0] }}</span></td>
<td class="code">{{ $current[1] }}</td>
<td class="code">{{ $current[2] }}</td>
</tr>
Would it be better to have named keys?
<tr>
<td><span class="method-tag method-tag-{{ strtolower($current['verb']) }}">{{ $current['verb] }}</span></td>
<td class="code">{{ $current['uri'] }}</td>
<td class="code">{{ $current['action'] }}</td>
</tr>
Hey Dayle
There seems to be an issue running Codeception with Anbu installed. First reported this issue with Codeception, but after some discussion, tracked down the issue to Anbu.
Here is a link to the issue I reported to Codeception for more information
So, when both of these tools are enabled (there are some unique features in both) Anbu is stepping on the toes of Laravel-Debugbar (or vise versa). I will cross post this on Laravel-Debugbar (maybe you two chaps can work together to make it happen)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.