PHPackages                             apitoolkit/apitoolkit-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. apitoolkit/apitoolkit-laravel

ActiveLibrary[HTTP &amp; Networking](/categories/http)

apitoolkit/apitoolkit-laravel
=============================

A PHP/Laravel SDK Wrapper for APIToolkit. It monitors incoming traffic, gathers the requests and sends the request to the apitoolkit servers.

v2.0.5(1y ago)57523MITPHP

Since Sep 9Pushed 1y ago1 watchersCompare

[ Source](https://github.com/apitoolkit/apitoolkit-laravel)[ Packagist](https://packagist.org/packages/apitoolkit/apitoolkit-laravel)[ RSS](/packages/apitoolkit-apitoolkit-laravel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (7)Versions (14)Used By (0)

[![APItoolkit's Logo](https://github.com/apitoolkit/.github/raw/main/images/logo-white.svg?raw=true#gh-dark-mode-only)](https://github.com/apitoolkit/.github/blob/main/images/logo-white.svg?raw=true#gh-dark-mode-only)[![APItoolkit's Logo](https://github.com/apitoolkit/.github/raw/main/images/logo-black.svg?raw=true#gh-light-mode-only)](https://github.com/apitoolkit/.github/blob/main/images/logo-black.svg?raw=true#gh-light-mode-only)

Laravel SDK
-----------

[](#laravel-sdk)

[![APItoolkit SDK](https://camo.githubusercontent.com/c07924272bb79bca125b3ffb2025db7c85c0fcd8f1e0840a5a3ff88cb4d15e0c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f415049746f6f6c6b69742d53444b2d3030363866663f6c6f676f3d6c61726176656c)](https://github.com/topics/apitoolkit-sdk) [![Join Discord Server](https://camo.githubusercontent.com/dd0cde65a806f8c74389de9910e309342b68f6f34323cb36639d49d891bd65be/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436861742d446973636f72642d373238396461)](https://apitoolkit.io/discord?utm_campaign=devrel&utm_medium=github&utm_source=sdks_readme) [![APItoolkit Docs](https://camo.githubusercontent.com/e564bf9ed10a447656c22b3abc4e1c41e684552580bc05043612215d99fe1a57/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f526561642d446f63732d303036386666)](https://apitoolkit.io/docs/sdks/php/laravel?utm_campaign=devrel&utm_medium=github&utm_source=sdks_readme)

APItoolkit is an end-to-end API and web services management toolkit for engineers and customer support teams. To integrate your Laravel (PHP) application with APItoolkit, you need to use this SDK to monitor incoming traffic, aggregate the requests, and then deliver them to the APItoolkit's servers.

---

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Open Telemetry Configuration](#setup-opentelemetry)
- [APItoolkit Middleware Setup](#setup-apitoolkit-middleware)
- [Contributing and Help](#contributing-and-help)
- [License](#license)

---

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

[](#installation)

Kindly run the command below to install the apitoolkit-laravel sdk and required otel packages:

```
composer require \
    open-telemetry/sdk \
    open-telemetry/exporter-otlp \
    apitoolkit/apitoolkit-laravel
```

Setup Opentelemetry
-------------------

[](#setup-opentelemetry)

#### Installing opentelemetry extension

[](#installing-opentelemetry-extension)

After installing the necessary packages, you'll need to install the opentelemetry extention and add it to your `php.ini` file

```
pecl install opentelemetry
```

Then add it to your `php.ini` file like so.

```
[opentelemetry]
extension=opentelemetry.so
```

export the following opentelemetry variables

```
export OTEL_PHP_AUTOLOAD_ENABLED=true
export OTEL_SERVICE_NAME=your-service-name
export OTEL_TRACES_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_ENDPOINT=http://otelcol.apitoolkit.io:4318
export OTEL_RESOURCE_ATTRIBUTES="at-project-key={ENTER_YOUR_API_KEY_HERE}"
export OTEL_PROPAGATORS=baggage,tracecontext
```

Setup APItoolkit Middleware
---------------------------

[](#setup-apitoolkit-middleware)

Next, register the middleware in the `app/Http/Kernel.php` file under the correct middleware group (e.g., `api`) or at the root, like so. This creates a customs spans which captures and sends http request info such as headers, requests and repsonse bodies, matched route etc. for each request

```
