Download the PHP package perfbase/php-sdk without Composer

On this page you can find all versions of the php package perfbase/php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-sdk

Perfbase

Perfbase PHP SDK

The official PHP SDK for Perfbase — application performance monitoring and profiling for PHP applications.

Packagist Version License CI PHP Version

Using a PHP framework?

If you're using a PHP framework, we recommend using our dedicated framework integrations for the best experience:

If you're not using a framework or need a custom integration, this SDK is for you.

Features

Requirements

Installation

1. Install the SDK

2. Install the Perfbase PHP Extension

The ext-perfbase PHP extension is required for the SDK to function. Install it using:

Important: Restart your web server or PHP-FPM service after installation.

3. Verify Installation

Quick Start

Basic Usage

Advanced Usage with Attributes

Multiple Concurrent Spans

Configuration Options

Basic Configuration

Feature Flags

Control which profiling features are enabled:

Available Feature Flags

Flag Description
UseCoarseClock Faster, less accurate timing (reduces overhead)
TrackCpuTime Monitor CPU time usage
TrackMemoryAllocation Track memory allocation patterns
TrackPdo Monitor database queries via PDO
TrackHttp Track outbound HTTP requests
TrackCaches Monitor cache operations (Redis, Memcached)
TrackMongodb Track MongoDB operations
TrackElasticsearch Monitor Elasticsearch queries
TrackQueues Track queue/background job operations
TrackAwsSdk Monitor AWS SDK operations
TrackFileOperations Track file I/O operations
TrackFileCompilation Monitor PHP file compilation
TrackFileDefinitions Track PHP class/function definitions
TrackExceptions Monitor exception handling
TrackErrors Monitor PHP errors, warnings, and notices
TrackMagicMethods Count magic method invocations

API Reference

Core Methods

startTraceSpan(string $spanName, array $attributes = []): void

Start profiling a named span with optional initial attributes.

Span names must be 1-64 characters and may only contain letters, numbers, hyphens, and underscores. Empty or whitespace-only names normalize to default.

stopTraceSpan(string $spanName): bool

Stop profiling a named span. Returns true if successful, false if span wasn't active.

setAttribute(string $key, string $value): void

Add a custom attribute to the current trace.

submitTrace(): SubmitResult

Submit collected profiling data to Perfbase. Resets the session on success; preserves trace state on failure so callers can decide whether to retry or discard.

The SDK sends the exact raw bytes returned by perfbase_get_data() as the request body. It adds the payload encoding version and client-created timestamp as HTTP headers; it does not JSON-wrap or base64-encode the trace payload.

The returned SubmitResult provides:

getTraceData(string $spanName = ''): string

Retrieve the raw Brotli-compressed MessagePack trace payload produced by the extension (useful for debugging or custom processing).

The current extension only supports whole-trace retrieval. Pass the default empty argument; the spanName parameter is kept only for backwards compatibility, and non-empty values are rejected.

reset(): void

Clear all active spans and reset the profiling session without submitting.

setFlags(int $flags): void

Change profiling feature flags at runtime.

isExtensionAvailable(): bool

Check if the Perfbase extension is loaded and available.

Static Methods

Perfbase::isAvailable(): bool

Static method to check extension availability without instantiating the class.

Error Handling

The SDK is designed to fail gracefully when the extension is not available:

Best Practices

1. Span Naming

Use descriptive, consistent span names:

Span names may only use letters, numbers, hyphens, and underscores, and must not exceed 64 characters.

2. Attribute Usage

Add meaningful context through attributes:

3. Error Handling in Spans

Always ensure spans are properly closed:

4. Performance Considerations

5. Forwarded Header Trust

EnvironmentUtils::getUserIp() is a best-effort helper. It reads common proxy/CDN headers when present, but it does not implement a trusted-proxy policy. Only use forwarded-header-derived IPs when your deployment sanitizes those headers at the edge.

Troubleshooting

Extension Not Found

Connection Issues

Debugging

Documentation

Full documentation is available at perfbase.com/docs.

License

Apache-2.0. See LICENSE.txt.


All versions of php-sdk with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4 <8.6
ext-curl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package perfbase/php-sdk contains the following files

Loading the files please wait ...