{"id":18386561,"url":"https://github.com/pinkeen/apidebugbundle","last_synced_at":"2026-04-24T16:03:08.652Z","repository":{"id":15531760,"uuid":"18266368","full_name":"pinkeen/ApiDebugBundle","owner":"pinkeen","description":"Provides web debug toolbar tab for easy API call debugging (Guzzle6 support).","archived":false,"fork":false,"pushed_at":"2019-03-01T13:15:28.000Z","size":117,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T02:09:47.354Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pinkeen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-30T15:00:47.000Z","updated_at":"2019-03-01T13:14:33.000Z","dependencies_parsed_at":"2022-08-27T00:12:00.027Z","dependency_job_id":null,"html_url":"https://github.com/pinkeen/ApiDebugBundle","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinkeen%2FApiDebugBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinkeen%2FApiDebugBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinkeen%2FApiDebugBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinkeen%2FApiDebugBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pinkeen","download_url":"https://codeload.github.com/pinkeen/ApiDebugBundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505931,"owners_count":21115354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T01:22:30.299Z","updated_at":"2026-04-24T16:03:03.616Z","avatar_url":"https://github.com/pinkeen.png","language":"PHP","readme":"ApiDebugBundle\n==============\n\n![ApiDebugBundle in action](Resources/doc/meta/images/apidebug.png)\n\nThis bundle adds a web debug toolbar tab which displays information about API consumer requests.\n\nIt aims to be universal and allow for easy integration with SDKs and HTTP client libraries.\n\nCurrently it supports [Guzzle 6](https://github.com/guzzle/guzzle) out-of-the box.\n\nIt should be extremely easy to integrate with any http client using PSR-7 messages.\n\nFor `Guzzle4`-compatible version use the `v1.0` tag.\n\nFor `Symfony \u003c 3.3`-compatible version use the `v2.0` tag.\n\n## Requirements\n\n* PHP 5.5.9\n* Symfony 3.3\n\n## Installation\n\nThe usual [Symfony stuff](http://symfony.com/doc/current/cookbook/bundles/installation.html).\n\nThe **composer.json** needs: `\"pinkeen/api-debug-bundle\": \"dev-master\",`.\n\nThe **AppKernel.php** needs: `new Pinkeen\\ApiDebugBundle\\PinkeenApiDebugBundle(),`.\n\nAdd the following to your `app/config/routing_dev.yml` if you want to be able to view raw body data:\n\n```yml\n_api_debug:\n    resource: \"@PinkeenApiDebugBundle/Resources/config/routing.yml\"\n    prefix:   /_profiler\n```\n\n## Services\n\n### New symfony approach\n\nAll services expect GuzzleClientFactory and RingPHPHandlerFactory are private,\nwhich means you cannot fetch services directly from the container via $container-\u003eget().\n\nThey are also automatically registered and set to autowire,\nall you need to do add type-hinted service to your class as an argument of contructor.\n\n```php\n// src/AppBundle/Service/FooService.php\n// ...\n\nuse Pinkeen\\ApiDebugBundle\\Bridge\\Guzzle\\Middleware\\DataCollectorMiddleware;\n\nclass FooService\n{\n    private $dataCollectorMiddleware;\n\n    public function __construct(DataCollectorMiddleware $dataCollectorMiddleware)\n    {\n        $this-\u003edataCollectorMiddleware = $dataCollectorMiddleware;\n    }\n\n    // ...\n}\n```\n\n## Usage\n\n### Integrate with your custom client\n\nFirstly you have to subclass \n[`AbstractCallData`](DataCollector/AbstractCallData.php) \nwhich holds data from a single API request.\n\nIf you are using a PSR-7 comptible client then you can use [`PsrCallData`](DataCollector\\Data\\PsrCallData.php)\ninstead of writing your own data class.\n\nThen every time your API consumer makes a request dispatch an [`ApiEvents::API_CALL`](ApiEvents.php) event.\n\n```php\n    use Pinkeen\\ApiDebugBundle\\ApiEvents;\n    use Pinkeen\\ApiDebugBundle\\Event\\ApiCallEvent;\n    \n    /* ... */\n    /** @var $eventDispatcher \\Symfony\\Component\\EventDispatcher\\EventDispatcher */\n    $eventDispatcher-\u003edispatch(\n        ApiEvents::API_CALL, \n        new ApiCallEvent(\n            new YourApiCallData(/* your params */)\n        )\n    );\n```\n\n### Guzzle\n\nYou've got two options here, either:\n\n*Let the bundle create the client for you...*\n\n```php\n    /** @var $guzzleClientFactory \\Pinkeen\\ApiDebugBundle\\Bridge\\Guzzle\\Service\\GuzzleClientFactory */\n    $guzzleClientFactory-\u003ecreate([\n        /* Guzzle client config (optional).\n         * It is passed directly to GuzzleHttp\\Client constructor. */\n    ]);\n```\n\n*... or push the collector handler to your middleware stack.*\n\n```php\n    $handler = new GuzzleHttp\\HandlerStack(new GuzzleHttp\\Handler\\CurlHandler());\n    /** @var $dataCollectorMiddleware \\Pinkeen\\ApiDebugBundle\\Bridge\\Guzzle\\Middleware\\DataCollectorMiddleware */\n    $dataCollectorMiddlewareHandler = $dataCollectorMiddleware-\u003egetHandler();\n    $handler-\u003epush($dataCollectorMiddlewareHandler);\n    $client = new GuzzleHttp\\Client(['handler' =\u003e $handler]);\n```\n\n### RingPHP\n\n*Let the bundle create the handler for you:*\n\n```php\n    /** @var $ringPHPHandlerFactory \\Pinkeen\\ApiDebugBundle\\Bridge\\RingPHP\\Service\\RingPHPHandlerFactory */\n    $handler = $ringPHPHandlerFactory-\u003ecreate(new CurlHandler());\n```\n\n*Use the collector_middleware service to create your RingPHP middleware and wrap it around your base handler:*\n\n```php\n    /** @var $dataCollectorMiddleware \\Pinkeen\\ApiDebugBundle\\Bridge\\RingPHP\\Middleware\\DataCollectorMiddleware */\n    $ringPhpHandler = $dataCollectorMiddleware-\u003ecreateHandler(new GuzzleHttp\\Ring\\Client\\CurlHandler(), 'apiname');\n```\n\nPS Nicely integrates with elasticsearch-php 2.0.\n\n## Production\n\nFor production environment you probably want to skip all of the data gathering.\n\nYou should take care of that yourself, unless you're using `Pinkeen\\ApiDebugBundle\\Bridge\\Guzzle\\Service\\GuzzleClientFactory` or\n`Pinkeen\\ApiDebugBundle\\Bridge\\RingPHP\\Service\\RingPHPHandlerFactory` which skip it when not in debug mode.\n\n## Notes \n\nI haven't found an easy way to get call duration out of guzzle6, so there's a regression here. If anybody has an idea\nplease give me a shout.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinkeen%2Fapidebugbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpinkeen%2Fapidebugbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinkeen%2Fapidebugbundle/lists"}