sevenspan / segment-php-sdk
A Segment bridge for Laravel
Requires
- php: ^8.1.0||^8.2
- illuminate/config: ^9.0|^10.0|^11.0
- illuminate/support: ^9.0|^10.0|^11.0
- segmentio/analytics-php: ~3.5.0 || ^3.7.0 || ^3.8.0
Requires (Dev)
- graham-campbell/analyzer: ^2.4 || ^3.0 || ^3.1 || ^4.0 || ^4.1
- graham-campbell/testbench: ^5.5 || ^6.0
- phpunit/phpunit: ^6.5 || ^7.5 || ^8.4 || ^9.0 || ^10.0 || ^11.0
This package is not auto-updated.
Last update: 2025-01-30 11:00:24 UTC
README
SevenSpan Segment is a Segment bridge for Laravel. This version requires PHP 8.2, and supports Laravel 9 and 10. Simply require the package using Composer:
$ composer require sevenspan/segment-php-sdk:^1.0
Once installed, if you are not using automatic package discovery, then you need to register the SevenSpan\SegmentPhpSdk\SegmentServiceProvider
service provider in your config/app.php
.
Configuration
SevenSpan Segment requires configuration.
To get started, you'll need to publish all vendor assets:
$ php artisan vendor:publish
This will create a config/segment.php
file in your app that you can modify to set your configuration. Also, make sure you check for changes to the original config file in this package between releases.
Usage
Once you've set your write_key
value in the configuration, you're ready to go! For the most part you can follow Segments own instructions however, you'll want to replace the Analytics
classname with Segment
- plus, you don't need to call class_alias
.
Identify the user
Segment::identify([ 'userId' => '12345abcde', 'traits' => [ 'name' => 'James Brooks', 'email' => 'test@test.com', ], ]);
Track actions
Segment::track([ 'userId' => '12345abcde', 'event' => 'Did something', 'properties' => [ 'was_awesome' => true, ], ]);
Security
Our full security policy is available to read here.
License
SevenSpan Segment is licensed under The MIT License (MIT).