VOOZH about

URL: https://deepwiki.com/rudderlabs/rudder-php-sdk

⇱ rudderlabs/rudder-php-sdk | DeepWiki


Loading...
Menu

Overview

The rudder-php-sdk is a server-side PHP library designed to integrate your applications with RudderStack, a customer data pipeline README.md1-6 It allows developers to collect event data from PHP applications and route it to a RudderStack data plane for processing and delivery to various destinations.

The SDK is a fork of Segment's analytics-php and has been modernized to support PHP 7.4 and 8.x README.md68-70 CHANGELOG.md58-60 It provides a robust, extensible architecture for capturing user identities, actions, and metadata.

Core Concepts

The SDK operates on a few primary entities:

  • The Facade: A static interface (Rudder) that serves as the main entry point for developers lib/Rudder.php1-50
  • The Client: The internal engine (Client) that handles message construction, UUID generation, and delegation to consumers lib/Client.php1-100
  • Consumers: Pluggable transport layers that determine how data is sent to the data plane (e.g., via cURL, sockets, or local files) README.md35-53

High-Level Interaction Diagram

The following diagram illustrates how a developer call moves from the public API into the internal transport layers.

User Interaction to Code Entity Mapping


Sources: lib/Rudder.php1-50 lib/Client.php1-100 README.md56-66

Architecture Summary

The SDK is designed for flexibility and performance. It supports various "consumers" to balance between application latency and delivery reliability.

ComponentRoleKey Code Entities
FacadeProvides a simple static API for event tracking.Rudder
OrchestratorManages configuration and event payload formatting.Client
TransportHandles the actual delivery of data to RudderStack.LibCurl, ForkCurl, Socket, File
CLICommand-line tool for manual event testing.bin/analytics

System Architecture Diagram

This diagram maps the functional components of the system to their specific file implementations.

System Architecture and File Mapping


Sources: lib/Rudder.php1-50 lib/Client.php1-100 composer.json35-38 README.md35-53

Key Features

  • Multiple Transport Options: Choose between synchronous cURL, asynchronous "fire-and-forget" fork-based cURL, raw TCP sockets, or local file logging README.md35-53
  • Batching & Queuing: Control memory and network usage via max_queue_size, flush_at, and max_queue_size_bytes CHANGELOG.md22-35 README.md43-52
  • Security & Reliability: Built-in support for Gzip compression (compress_request), SSL/TLS verification, and exponential backoff for retrying network errors CHANGELOG.md30-42 README.md40-47
  • CLI Utility: Includes a bin/analytics script for sending events directly from the terminal bin/analytics1-85

Next Steps

To dive deeper into the implementation and usage of the SDK, refer to the following child pages:

  • Getting Started: A step-by-step guide for installation via Composer and making your first track call.
  • SDK Configuration Reference: Detailed documentation on all initialization parameters, including consumer selection and performance tuning.

Sources: README.md8-54 composer.json1-47 CHANGELOG.md17-37