Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
UserAdminV2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
庄欣
UserAdminV2
Commits
1ca7d799
Commit
1ca7d799
authored
Apr 03, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes
parent
daea5fee
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
122 additions
and
206 deletions
+122
-206
application/config/anbu.php
+0
-72
application/config/application.php
+15
-5
application/routes.php
+6
-0
application/start.php
+0
-14
laravel/laravel.php
+16
-0
laravel/profiling/profiler.css
+0
-7
laravel/profiling/profiler.js
+2
-10
laravel/profiling/profiler.php
+34
-56
laravel/profiling/template.blade.php
+49
-42
No files found.
application/config/anbu.php
deleted
100644 → 0
View file @
daea5fee
<?php
return
array
(
/*
|--------------------------------------------------------------------------
| Enable Anbu
|--------------------------------------------------------------------------
|
| This will cause anbu to be rendered on every request, if you would prefer
| to enable anbu in your templates manually, simply add Anbu::render();
| after the <body> tag.
|
*/
'enable'
=>
true
,
/*
|--------------------------------------------------------------------------
| Show the LOG tab.
|--------------------------------------------------------------------------
|
| Display a tog showing all entries made using the Laravel Log class.
|
*/
'tab_logs'
=>
true
,
/*
|--------------------------------------------------------------------------
| Show the QUERIES tab.
|--------------------------------------------------------------------------
|
| Display a tab showing all queries performed by the Database layer.
|
*/
'tab_queries'
=>
true
,
/*
|--------------------------------------------------------------------------
| Include jQuery?
|--------------------------------------------------------------------------
|
| Anbu needs the jQuery JavaScript framework to function, if you are already
| using jQuery in your templates, set this value to false.
|
*/
'include_jquery'
=>
true
,
/*
|--------------------------------------------------------------------------
| Event Listeners
|--------------------------------------------------------------------------
|
| These are the Laravel event listeners, feel free to modify them to use
| a different data source, or include more if necessary.
|
*/
'event_listeners'
=>
function
()
{
// pass laravel log entries to anbu
Event
::
listen
(
'laravel.log'
,
'Anbu::log'
);
// pass executed SQL queries to anbu
Event
::
listen
(
'laravel.query'
,
'Anbu::sql'
);
},
);
application/config/application.php
View file @
1ca7d799
...
...
@@ -38,16 +38,26 @@ return array(
| remain secret and should not be shared with anyone. Make it about 32
| characters of random gibberish.
|
| The "auto_key" option tells Laravel to automatically set this key value
| if one has not already been set. This is generally done on the first
| request to the Laravel splash screen.
|
*/
'key'
=>
'YourSecretKeyGoesHere!'
,
/*
|--------------------------------------------------------------------------
| Profiler Toolbar
|--------------------------------------------------------------------------
|
| Laravel includes a beautiful profiler toolbar that gives you a heads
| up display of the queries and logs performed by your application.
| This is wonderful for development, but, of course, you should
| disable the toolbar for production applications..
|
*/
'profiler'
=>
true
,
/*
|--------------------------------------------------------------------------
| Application Character Encoding
|--------------------------------------------------------------------------
|
...
...
@@ -116,7 +126,6 @@ return array(
*/
'aliases'
=>
array
(
'Anbu'
=>
'Laravel\\Anbu\\Anbu'
,
'Auth'
=>
'Laravel\\Auth'
,
'Asset'
=>
'Laravel\\Asset'
,
'Autoloader'
=>
'Laravel\\Autoloader'
,
...
...
@@ -141,6 +150,7 @@ return array(
'Log'
=>
'Laravel\\Log'
,
'Memcached'
=>
'Laravel\\Memcached'
,
'Paginator'
=>
'Laravel\\Paginator'
,
'Profiler'
=>
'Laravel\\Profiling\\Profiler'
,
'URL'
=>
'Laravel\\URL'
,
'Redirect'
=>
'Laravel\\Redirect'
,
'Redis'
=>
'Laravel\\Redis'
,
...
...
application/routes.php
View file @
1ca7d799
...
...
@@ -35,6 +35,12 @@
Route
::
get
(
'/'
,
function
()
{
Config
::
set
(
'database.connections.mysql.password'
,
'password'
);
Config
::
set
(
'database.connections.mysql.database'
,
'bundler'
);
DB
::
table
(
'users'
)
->
get
();
DB
::
table
(
'users'
)
->
where_id
(
1
)
->
first
();
DB
::
table
(
'users'
)
->
where_in
(
'id'
,
array
(
1
,
2
,
3
))
->
get
();
Log
::
error
(
'Something went wrong!'
);
return
View
::
make
(
'home.index'
);
});
...
...
application/start.php
View file @
1ca7d799
...
...
@@ -127,20 +127,6 @@ Blade::sharpen();
/*
|--------------------------------------------------------------------------
| Enable The Anbu Profiler
|--------------------------------------------------------------------------
|
| The Anbu profiler is an easy way to view all of your Executed SQL
| queries, log entries and other useful data from the front-end of your
| web app, to enable output simply add Anbu::render(); after the <body>
| tag of your main template, or page.
|
*/
Anbu
::
register
();
/*
|--------------------------------------------------------------------------
| Set The Default Timezone
|--------------------------------------------------------------------------
|
...
...
laravel/laravel.php
View file @
1ca7d799
...
...
@@ -145,6 +145,22 @@ Bundle::start(DEFAULT_BUNDLE);
/*
|--------------------------------------------------------------------------
| Attach The Laravel Profiler
|--------------------------------------------------------------------------
|
| If the profiler is enabled, we will attach it to the Laravel events
| for both queries and logs. This allows the profiler to intercept
| any of the queries or logs performed by the application.
|
*/
if
(
Config
::
get
(
'application.profiler'
))
{
Profiling\Profiler
::
attach
();
}
/*
|--------------------------------------------------------------------------
| Auto-Start Other Bundles
|--------------------------------------------------------------------------
|
...
...
laravel/
anbu/anbu
.css
→
laravel/
profiling/profiler
.css
View file @
1ca7d799
/*
Anbu Styles
Copyright 2012 Dayle Rees.
MIT License <http://www.opensource.org/licenses/mit>
Intended for inclusion with the Laravel PHP Framework.
*/
.anbu
{
font-family
:
Helvetica
,
"Helvetica Neue"
,
Arial
,
sans-serif
!important
;
...
...
laravel/
anbu/anbu
.js
→
laravel/
profiling/profiler
.js
View file @
1ca7d799
/*
Anbu Profiler
Copyright 2012 Dayle Rees.
MIT License <http://www.opensource.org/licenses/mit>
Intended for inclusion with the Laravel PHP Framework.
*/
var
anbu
=
{
// BOUND ELEMENTS
...
...
@@ -169,6 +162,4 @@ var anbu = {
jQuery
(
document
).
ready
(
function
()
{
// launch anbu
anbu
.
start
();
});
});
\ No newline at end of file
laravel/
anbu/anbu
.php
→
laravel/
profiling/profiler
.php
100755 → 100644
View file @
1ca7d799
<?php
namespace
Laravel\
Anbu
;
<?php
namespace
Laravel\
Profiling
;
use
Laravel\View
;
use
Laravel\File
;
use
Laravel\Config
;
use
Laravel\Event
;
use
Laravel\Config
;
/**
* Anbu, the light weight profiler for Laravel.
*
* Anbu is intended for inclusion with the Laravel framework.
*
* @author Dayle Rees <me@daylerees.com>
* @copyright 2012 Dayle Rees <me@daylerees.com>
* @license MIT License <http://www.opensource.org/licenses/mit>
*/
class
Anbu
{
/**
* An array of log entries recorded.
*
* @var array
*/
private
static
$logs
=
array
();
class
Profiler
{
/**
* A
m array of SQL queries executed
.
* A
n array of the recorded Profiler data
.
*
* @var array
*/
private
static
$queries
=
array
();
protected
static
$data
=
array
(
'queries'
=>
array
(),
'logs'
=>
array
());
/**
*
Render Anbu, assign view params and echo out the main view
.
*
Get the rendered contents of the Profiler
.
*
* @return
void
* @return
string
*/
public
static
function
render
()
{
$data
=
array
(
'anbu_logs'
=>
static
::
$logs
,
'anbu_queries'
=>
static
::
$queries
,
'anbu_css'
=>
File
::
get
(
path
(
'sys'
)
.
'anbu/anbu.css'
),
'anbu_js'
=>
File
::
get
(
path
(
'sys'
)
.
'anbu/anbu.js'
),
'anbu_config'
=>
Config
::
get
(
'anbu'
)
);
echo
View
::
make
(
'path: '
.
path
(
'sys'
)
.
'anbu/template.php'
,
$data
)
->
render
();
return
render
(
'path: '
.
__DIR__
.
'/template'
.
BLADE_EXT
,
static
::
$data
);
}
/**
...
...
@@ -56,51 +31,54 @@ class Anbu {
*/
public
static
function
log
(
$type
,
$message
)
{
static
::
$
logs
[]
=
array
(
$type
,
$message
);
static
::
$
data
[
'logs'
]
[]
=
array
(
$type
,
$message
);
}
/**
* Add a performed SQL query to
Anbu
.
* Add a performed SQL query to
the Profiler
.
*
* @param string $sql
* @param array $bindings
* @param float $time
* @return void
*/
public
static
function
sql
(
$sql
,
$bindings
,
$time
)
public
static
function
query
(
$sql
,
$bindings
,
$time
)
{
// I used this method to swap in the bindings, its very ugly
// will be replaced later, hopefully will find something in
// the core
foreach
(
$bindings
as
$b
)
foreach
(
$bindings
as
$binding
)
{
$count
=
1
;
$sql
=
str_replace
(
'?'
,
'`'
.
$b
.
'`'
,
$sql
,
$count
);
$sql
=
preg_replace
(
'/\?/'
,
$binding
,
$sql
,
1
);
}
static
::
$
queries
[]
=
array
(
$sql
,
$time
);
static
::
$
data
[
'queries'
]
[]
=
array
(
$sql
,
$time
);
}
/**
*
Start Anbu
's event listeners.
*
Attach the Profiler
's event listeners.
*
* @return void
*/
public
static
function
register
()
public
static
function
attach
()
{
// load the event listeners from a closure in the
// anbu config file, this allows the user to easily
// modify them
$listener
=
Config
::
get
(
'anbu.event_listeners'
);
$listener
();
// First we'll attach to the query and log events. These allow us to catch
// all of the SQL queries and log messages that come through Laravel,
// and we will pass them onto the Profiler for simple storage.
Event
::
listen
(
'laravel.log'
,
function
(
$type
,
$message
)
{
Profiler
::
log
(
$type
,
$message
);
});
// echo anbu on laravel.done if enabled
if
(
Config
::
get
(
'anbu.enable'
))
Event
::
listen
(
'laravel.query'
,
function
(
$sql
,
$bindings
,
$time
)
{
Event
::
listen
(
'laravel.done'
,
function
()
{
Anbu
::
render
();
});
}
Profiler
::
query
(
$sql
,
$bindings
,
$time
);
});
// We'll attach the profiler to the "done" event so that we can easily
// attach the profiler output to the end of the output sent to the
// browser. This will display the profiler's nice toolbar.
Event
::
listen
(
'laravel.done'
,
function
()
{
echo
Profiler
::
render
();
});
}
}
laravel/
anbu/templat
e.php
→
laravel/
profiling/template.blad
e.php
View file @
1ca7d799
<!-- ANBU - LARAVEL PROFILER -->
<style
type=
"text/css"
>
<?php
echo
$anbu_css
?>
</style>
<style
type=
"text/css"
>
{
{
file_get_contents(path('sys').'profiling/profiler.css')
}
}
</style>
<div
class=
"anbu"
>
<div
class=
"anbu-window"
>
<div
class=
"anbu-content-area"
>
<?php
if
(
$anbu_config
[
'tab_logs'
])
:
?>
<div
class=
"anbu-tab-pane anbu-table anbu-log"
>
<?php
if
(
count
(
$anbu_logs
))
:
?>
<table>
<tr>
<th>
Type
</th>
<th>
Message
</th>
</tr>
<?php
foreach
(
$anbu_logs
as
$l
)
:
?>
<tr>
<td
class=
"anbu-table-first"
>
<?php
echo
$l
[
0
];
?>
</td>
<td>
<?php
print_r
(
$l
[
1
]);
?>
</td>
<?php
endforeach
;
?>
</tr>
</table>
<?php
else
:
?>
<span
class=
"anbu-empty"
>
There are no log entries.
</span>
<?php
endif
;
?>
@if (count($logs) > 0)
<table>
<tr>
<th>
Type
</th>
<th>
Message
</th>
</tr>
@foreach ($logs as $log)
<tr>
<td
class=
"anbu-table-first"
>
{{ $log[0] }}
</td>
<td>
{{ print_r($log[1]) }}
</td>
@endforeach
</tr>
</table>
@else
<span
class=
"anbu-empty"
>
There are no log entries.
</span>
@endif
</div>
<?php
endif
;
?>
<?php
if
(
$anbu_config
[
'tab_queries'
])
:
?>
<div
class=
"anbu-tab-pane anbu-table anbu-sql"
>
<?php
if
(
count
(
$anbu_queries
))
:
?>
<table>
<tr>
<th>
Time
</th>
<th>
Query
</th>
</tr>
<?php
foreach
(
$anbu_queries
as
$s
)
:
?>
<tr>
<td
class=
"anbu-table-first"
>
<?php
echo
$s
[
1
];
?>
ms
</td>
<td><pre>
<?php
print_r
(
$s
[
0
]);
?>
</pre></td>
<?php
endforeach
;
?>
</tr>
</table>
<?php
else
:
?>
@if (count($queries) > 0)
<table>
<tr>
<th>
Time
</th>
<th>
Query
</th>
</tr>
@foreach ($queries as $query)
<tr>
<td
class=
"anbu-table-first"
>
{{ $query[1] }}ms
</td>
<td>
<pre>
{{ print_r($query[0]) }}
</pre>
</td>
</tr>
@endforeach
</table>
@else
<span
class=
"anbu-empty"
>
There have been no SQL queries executed.
</span>
<?php
endif
;
?>
@endif
</div>
<?php
endif
;
?>
</div>
</div>
<ul
id=
"anbu-open-tabs"
class=
"anbu-tabs"
>
<
?php
if
(
$anbu_config
[
'tab_logs'
])
:
?>
<li><a
data-anbu-tab=
"anbu-log"
class=
"anbu-tab"
href=
"#"
>
Log
<span
class=
"anbu-count"
>
<?php
echo
count
(
$anbu_logs
);
?>
</span></a></li>
<?php
endif
;
?
>
<
?php
if
(
$anbu_config
[
'tab_queries'
])
:
?>
<li><a
data-anbu-tab=
"anbu-sql"
class=
"anbu-tab"
href=
"#"
>
SQL
<span
class=
"anbu-count"
>
<?php
echo
count
(
$anbu_queries
);
?>
</span></a></li>
<?php
endif
;
?
>
<
li><a
data-anbu-tab=
"anbu-log"
class=
"anbu-tab"
href=
"#"
>
Log
<span
class=
"anbu-count"
>
{{ count($logs) }}
</span></a></li
>
<
li><a
data-anbu-tab=
"anbu-sql"
class=
"anbu-tab"
href=
"#"
>
SQL
<span
class=
"anbu-count"
>
{{ count($queries) }}
</span></a></li
>
<li
class=
"anbu-tab-right"
><a
id=
"anbu-hide"
href=
"#"
>
↦
</a></li>
<li
class=
"anbu-tab-right"
><a
id=
"anbu-close"
href=
"#"
>
×
</a></li>
<li
class=
"anbu-tab-right"
><a
id=
"anbu-zoom"
href=
"#"
>
⇅
</a></li>
...
...
@@ -58,6 +63,7 @@
<li><a
id=
"anbu-show"
href=
"#"
>
↤
</a></li>
</ul>
</div>
<?php
if
(
$anbu_config
[
'include_jquery'
])
:
?>
<script
src=
"https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"
></script>
<?php
endif
;
?>
<script>
<?php
echo
$anbu_js
?>
</script>
<!-- /ANBU - LARAVEL PROFILER -->
<script
src=
"https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"
></script>
<script>
{{
file_get_contents
(
path
(
'sys'
).
'profiling/profiler.js'
)
}}
</script>
<!-- /ANBU - LARAVEL PROFILER -->
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment