PHP Integration

Add rustalytics to your PHP app in under 5 minutes

Installation

Install via Composer:

composer require rustalytics/php

Basic Usage

1. Initialize the tracker in your application:

// config.php or similar
require_once 'vendor/autoload.php';

use Rustalytics\Tracker;

$tracker = new Tracker([
    'projectId' => 'your-project-id',
    'apiKey' => 'your-api-key'
]);

2. Track page views automatically by adding this to your header:

<?php
// At the top of your template/header file
$tracker->pageView();
?>

3. Track custom events:

// Track a custom event
$tracker->track('signup_completed', [
    'user_id' => $userId,
    'plan' => 'premium'
]);

Framework Integration

Laravel

Check our Laravel integration guide for framework-specific setup.

Symfony

For Symfony, use our bundle:

composer require rustalytics/symfony-bundle

Configuration Options

projectId *

Your rustalytics project ID (required)

apiKey *

Your rustalytics API key (required)

endpoint

Custom API endpoint (optional)

Need Help?

If you need any help with the integration, feel free to: