perfbase/php-sdk

An SDK for sending profiling data to Perfbase

dev-main 2024-11-07 15:57 UTC

This package is auto-updated.

Last update: 2024-11-07 15:58:00 UTC


README

A PHP SDK for sending application profiling data to Perfbase. This SDK allows you to easily integrate performance monitoring into your PHP applications.

Installation

Install the package via composer:

composer require perfbase/php-sdk

Requirements

  • PHP 8.0 or higher
  • Composer

Quick Start

use Perfbase\SDK\Client;
use Perfbase\SDK\Config;

// Initialize the client
$client = new Client(new Config(
    apiKey: 'your-api-key'
));

// Start profiling
$client->startProfiling();

// Your code here
// ...

// Stop profiling and send data
$client->stopProfiling();

Configuration

You can configure the SDK using either direct initialization or an array:

// Direct initialization
$config = new Config(
    apiKey: 'your-api-key',
    apiUrl: 'https://api.perfbase.com/v1', // Optional
    enabled: true,                         // Optional
    timeout: 1                             // Optional
);

// Or using an array
$config = Config::fromArray([
    'api_key' => 'your-api-key',
    'api_url' => 'https://api.perfbase.com/v1',
    'enabled' => true,
    'timeout' => 1
]);

Configuration Options

Collected Data

The SDK collects the following metrics:

  • Timestamp
  • Duration
  • Memory peak usage
  • Stack traces with:
    • File and line information
    • Function names
    • Execution time
    • Memory usage

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Support

For support, please contact support@perfbase.com or visit our documentation.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.