承接 synchro/segment 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

synchro/segment

最新稳定版本:v5.0.0

Composer 安装命令:

composer require synchro/segment

包简介

A Segment bridge for Laravel

README 文档

README

Build Status Packagist Downloads Latest Version

This package is a Segment bridge for Laravel, which relies on Segment's own PHP library. This version requires PHP 8.2 and up, and supports Laravel 11 – 12. This package was originally written by Graham Campbell for Alt Three, but was abandoned in April 2022. This fork was resurrected in April 2023 by Marcus Bointon (@Synchro).

Installation

Install the package using Composer:

Version 4.0 of this package supports Laravel 9 and 10, and requires PHP 8.1 or later.

$ composer require synchro/segment:^4.0

Version 5.0 of this package supports Laravel 11 and 12, and requires PHP 8.2 or later.

$ composer require synchro/segment:^5.0

Once installed, if you are not using automatic package discovery, then you need to register the Synchro\Segment\SegmentServiceProvider service provider in your config/app.php.

Configuration

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 Segment's 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,
    ],
]);

Tests

Run tests with ./vendor.bin/phpunit or composer test.

Coding standards

Coding standards are checked and enforced using Laravel Pint using the default Laravel coding standard. Check for coding standards and apply automatic fixes by running ./vendor/bin/pint or composer cs. These checks are also run using GitHub actions.

Security

Our security policy is available to read here.

License

This library is licensed under The MIT License (MIT).

统计信息

  • 总下载量: 33
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 42
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-04-12