2017 © Pedro Peláez
 

symfony-bundle api-profiler-bundle

A Symfony 2 bundle to add an API Profiler to the debug toolbar

image

chrisjohnson00/api-profiler-bundle

A Symfony 2 bundle to add an API Profiler to the debug toolbar

  • Friday, April 4, 2014
  • by chrisjohnson00
  • Repository
  • 1 Watchers
  • 2 Stars
  • 247 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

ApiProfilerBundle

This bundle adds a REST API profiler/debugger to the Symfony 2 Profiler, (*1)

Continuous Integration

Build Status Scrutinizer Quality Score Code Coverage, (*2)

Installation

Installation by Composer

Add ApiProfilerBundle bundle as a dependency to the composer.json of your application, (*3)

"require": {
    ...
    "chrisjohnson00/api-profiler-bundle": "dev-master"
    ...
},

Or on the command line with composer require chrisjohnson00/api-profiler-bundle, (*4)

Add ApiProfilerBundle to your application kernel.

// app/AppKernel.php
<?php
    // ...
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new ChrisJohnson00\ApiProfilerBundle\ChrisJohnson00ApiProfilerBundle(),
        );
    }

Configuration

To change the default warning & error thresholds (used for coloring in the toolbar), you can add these configs. Note: these configs are completely optional!, (*5)

chris_johnson00_api_profiler:

    # Changes the warning threshold time (ms).  This is used to change the toolbar to yellow when the total response time is > this value
    warning_threshold:    5000 # Example: 5000

    # Changes the error threshold time (ms).  This is used to change the toolbar to red when the total response time is > this value
    error_threshold:      10000 # Example: 10000

Usage

A service will be registered by the name of data_collector.api_request. To have API request information included in the profiler, you must attach the profile data using the service., (*6)

$theService->attachData($theURL,
                        $theRequestMethod,
                        $theRequestHeadersAsAnAssociativeArray,
                        $theRequestBody,
                        $theResponseTimeInMilliseconds,
                        $theResponseHeadersAsAnAssociativeArray,
                        $theHTTPStatusCode,
                        $theResponseBody);

Here's the full signature:, (*7)

public function attachData( $url,
                            $method,
                            $requestHeaders = array(),
                            $requestBody = null,
                            $time,
                            $responseHeaders = array(),
                            $statusCode,
                            $responseBody = null)

Here's a simple example:, (*8)

$theService->attachData("http://localhost/api/status",
                        "GET",
                        array('User-Agent'=>'My fancy application'),
                        null,
                        125,
                        array('Date'=>'Mon, 07 Oct 2013 00:50:46 GMT','Server'=>'Apache'),
                        200,
                        "Everything is groovy!!");

The Versions

04/04 2014

dev-master

9999999-dev

A Symfony 2 bundle to add an API Profiler to the debug toolbar

  Sources   Download

MIT

The Requires

 

api debug profile toolbar

22/11 2013

1.0.1

1.0.1.0

A Symfony 2 bundle to add an API Profiler to the debug toolbar

  Sources   Download

MIT

The Requires

 

api debug profile toolbar

11/10 2013

1.0

1.0.0.0

A Symfony 2 bundle to add an API Profiler to the debug toolbar

  Sources   Download

MIT

The Requires

 

api debug profile toolbar