Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Rudder Php Sdk

Rudder Php Sdk Laravel Package

rudderstack/rudder-php-sdk

RudderStack PHP SDK lets PHP applications send track, identify, page, and screen events to RudderStack’s customer data pipeline, with configurable queueing, batching, debug logging, and lib_curl consumer support.

View on GitHub
Deep Wiki
Context7

The RudderStack PHP SDK lets PHP applications send analytics events to a customer data pipeline for routing to warehouses, marketing tools, and other destinations. Initialize the Client with your write key and optional settings like data_plane_url, consumer, debug, max_queue_size, and flush_at.

  • Event tracking via identify, track, page, group, and alias calls
  • Asynchronous queuing with configurable flush_at and max_queue_size
  • Pluggable consumers, including lib_curl for HTTP delivery
  • Debug mode for logging and blocking response waits
  • Composer installation with simple static Rudder::init() setup
Frequently asked questions about Rudder Php Sdk
How do I integrate RudderStack’s PHP SDK into a Laravel application for real-time event tracking?
Use Laravel’s Service Provider to bind the Rudder client to the container, then inject it into controllers or listeners. For example, register it in `AppServiceProvider` with `Rudder::init()` and access it via `app('rudder')`. Trigger events like `track()` or `page()` in listeners tied to Laravel’s event system.
Does the RudderStack PHP SDK support Laravel’s queue system for batch processing?
Yes, the SDK supports batch processing via `flush_at` and `max_queue_size` parameters. Configure these in the SDK initialization to align with Laravel’s queue workers (e.g., Redis or database queues). This ensures events are processed asynchronously without blocking HTTP requests.
What Laravel versions and PHP versions does the RudderStack PHP SDK support?
The SDK is compatible with Laravel 8.0+ and PHP 8.0+. Verify compatibility by checking the SDK’s `composer.json` for PHP version constraints. Test thoroughly with your Laravel version, especially if using newer features like Laravel 10’s improved queue handling.
How can I handle GDPR compliance with RudderStack in a Laravel app?
RudderStack enforces data governance via its pipeline, but Laravel must also manage user consent and data retention. Use middleware to validate consent before sending events, and implement RudderStack’s `delete` API calls for GDPR requests. Audit logs via `debug: true` to verify compliance.
What’s the best way to debug RudderStack events in Laravel without cluttering logs?
Enable `debug: true` in the SDK initialization, then route logs to a custom Monolog channel (e.g., `single` or `syslog`). This separates RudderStack logs from Laravel’s default logs. Use `Rudder::getLogger()` to access debug output programmatically.
Can I use RudderStack’s PHP SDK to send events to multiple destinations (e.g., Snowflake and Amplitude) simultaneously?
Yes, RudderStack supports multi-destination routing via its `destinations` configuration. Define routes in the RudderStack dashboard or via the SDK’s `route` method. However, this adds complexity—test thoroughly to ensure event consistency across destinations.
How do I mock RudderStack’s API for unit testing in Laravel?
Use Mockery or PHPUnit’s mock builder to stub the `Rudder` client. Replace the real `data_plane_url` with a local endpoint (e.g., `http://localhost:8000/mock-rudder`) and assert events are sent correctly. For integration tests, use contract testing to verify API responses.
What happens if RudderStack’s data plane is down? How can I implement a fallback?
The SDK will queue events locally until the connection is restored. Implement a circuit breaker (e.g., `spatie/fractal`) to detect failures and fallback to storing events in a database table. Use Laravel’s `Retry` facade with exponential backoff for automatic retries.
How do I auto-track page views or API calls in Laravel using RudderStack?
Create middleware (e.g., `TrackPageViewMiddleware`) that extends Laravel’s `Middleware` class. In the `handle` method, use `app('rudder')->page()` with request data like `url`, `title`, and `properties`. Bind the middleware to routes or globally in `app/Http/Kernel.php`.
Are there cost implications for high-volume event tracking with RudderStack in Laravel?
Costs depend on RudderStack’s pricing model (e.g., per-event or per-destination fees) and your Laravel app’s traffic. Optimize by tuning `flush_at` to batch events (e.g., 100–500 events per batch) and monitor egress costs via RudderStack’s dashboard or Laravel’s Horizon for queue metrics.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource