Skip to content

Commit

Permalink
Merge pull request #1 from maxromanovsky/composer
Browse files Browse the repository at this point in the history
Composer support added + minor UI improvements
  • Loading branch information
johannes committed Mar 22, 2013
2 parents 964773f + 977f5d0 commit 886edda
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 22 deletions.
25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright (c) 2012, Johannes Schlüter <johannes@schlueters.de>
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name JSMysqlndBundle nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 changes: 15 additions & 6 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ Requirements
-----------

For making use of this bundle you need Symfony2 running on a PHP setup
where the mysqli extension is activated and mysqlnd is being used. The mysqli
extension is only used to retrieve data. It is no requirement for your
application to use to use mysqli. Applications using Doctrine and PDO are
where the mysqli extension is activated and mysqlnd is being used. The mysqli
extension is only used to retrieve data. It is no requirement for your
application to use to use mysqli. Applications using Doctrine and PDO are
fully supported.

Installation
------------

Installation is a quick process:

1. Download JSMysqlndBundle
1. Download JSMysqlndBundle or install it via Composer
2. Configure the Autoloader
3. Enable the Bundle

Expand All @@ -29,10 +29,17 @@ Ultimately, the JSMysqlndBundle files should be downloaded to the
`vendor/bundles/JS/MysqlndBundle` directory.

This can be done in several ways, depending on your preference. The first
method is the standard Symfony2 method.
method is the standard method for Symfony 2.1+.

**Using Composer**

``` bash
$ php composer.phar require "js/mysqlnd-bundle=dev-master"
```

**Using the vendors script**

This method is the standard method for Symfony 2.0
Add the following lines in your `deps` file:

```
Expand All @@ -58,6 +65,8 @@ $ git submodule update --init

### Step 2: Configure the Autoloader

This step should be omitted if you used Composer to install this Bundle.

Add the `JS` namespace to your autoloader:

``` php
Expand Down Expand Up @@ -87,7 +96,7 @@ public function registerBundles()

if (in_array($this->getEnvironment(), array('dev', 'test'))) {
// ...
$bundles[] = new JS/MysqlndBundle();
$bundles[] = new \JS\MysqlndBundle\JSMysqlndBundle();
}
}
```
44 changes: 28 additions & 16 deletions Resources/views/Collector/mysqlnd.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,17 @@

{% if collector.statistics %}
<table>
{% for key, value in collector.statistics %}
<tr><td>{{ key }}</td><td>{{ value }}</td></tr>
{% endfor %}
<thead>
<tr>
<th scope="col">Key</th>
<th scope="col">Value</th>
</tr>
</thead>
<tbody>
{% for key, value in collector.statistics %}
<tr><th>{{ key }}</th><td>{{ value }}</td></tr>
{% endfor %}
</tbody>
</table>
<p>Documentation on the individual statistics can be found on <a href="http://php.net/mysqlnd.stats">http://php.net/mysqlnd.stats</a>.</p>
{% else %}
Expand All @@ -40,24 +48,28 @@

<div id="JSMysqlndQC">
<h2>mysqlnd_qc Query Tracing</h2>

{% if collector.MysqlndQCTrace %}
<table>
<tr><td>No.</td><td>Run time</td><td>Store Time</td><td>Cachable</td></tr>
{% for key, value in collector.MysqlndQCTrace %}
<tr><td colspan="5"><strong>{{ value['query'] }}</strong></td></tr>
<tr><td>#{{ key+1 }}</td>
<td>{{ value['run_time'] }} ms</td>
<td>{{ value['store_time'] }} ms</td>
<td>{% if value['eligible_for_caching'] %}Cachable{% else %}Not cachable{% endif %}</td>
<td><a href="#" onclick="document.getElementById('JSMysqlndQCStacktrace{{ key+1 }}').style.display='inline'; return false;">Stacktrace</a></td>
</tr>
<tr><td colspan="5" style="overflow: scroll"><pre id="JSMysqlndQCStacktrace{{ key+1 }}" style="display:none;">{{ value['origin'] }}</pre></td></tr>
{% endfor %}
<thead>
<tr><th>No.</th><th>Run time</th><th>Store Time</th><th>Cachable</th></tr>
</thead>
<tbody>
{% for key, value in collector.MysqlndQCTrace %}
<tr><td colspan="5"><strong>{{ value['query'] }}</strong></td></tr>
<tr><th>#{{ key+1 }}</th>
<td>{{ value['run_time'] }} ms</td>
<td>{{ value['store_time'] }} ms</td>
<td>{% if value['eligible_for_caching'] %}Cachable{% else %}Not cachable{% endif %}</td>
<td><a href="#" onclick="document.getElementById('JSMysqlndQCStacktrace{{ key+1 }}').style.display='inline'; return false;">Stacktrace</a></td>
</tr>
<tr><td colspan="5" style="overflow: scroll"><pre id="JSMysqlndQCStacktrace{{ key+1 }}" style="display:none;">{{ value['origin'] }}</pre></td></tr>
{% endfor %}
</tbody>
</table>
{% else %}
<strong>No myslqnd_qc traces collected for this request.</strong>
<p>For collecting trace data PHP requires the <a href="http://php.net/mysqlnd_qc">mysqlnd_qc extension</a> and <i>mysqlnd_qc.collect_query_trace</i> has to be enabled in php.ini.</p>
{% endif %}
</div>
</div>
{% endblock %}
38 changes: 38 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "js/mysqlnd-bundle",
"type": "symfony-bundle",
"description": "The JSMysqlndBundle is an extension to the Symfony2 profiling toolbar. It extends the data collection with information gathered from PHP's mysqlnd database driver, giving more insight on the performance.",
"keywords": ["database", "mysql", "mysqlnd", "profiler"],
"homepage": "https://github.com/johannes/JSMysqlndBundle",
"license": "BSD-3-Clause",
"authors": [
{
"name": "Johannes Schlüter",
"homepage": "http://schlueters.de"
},
{
"name": "Max Romanovsky",
"homepage": "http://maxromanovsky.com"
},
{
"name": "Symfony Community",
"homepage": "https://github.com/johannes/JSMysqlndBundle/contributors"
}
],
"minimum-stability": "dev",
"require": {
"php": ">=5.3.2",
"ext-mysqli": "*",
"ext-mysqlnd": "*",
"symfony/framework-bundle": ">=2.0,<2.3-dev"
},
"suggest": {
"ext-mysqlnd_qc": "Required for Query Tracing"
},
"autoload": {
"psr-0": {
"JS\\MysqlndBundle": ""
}
},
"target-dir": "JS/MysqlndBundle"
}

0 comments on commit 886edda

Please sign in to comment.