{"id":19235416,"url":"https://github.com/growingio/growingio-php-sdk","last_synced_at":"2025-04-21T05:32:03.023Z","repository":{"id":16008647,"uuid":"332936455","full_name":"growingio/growingio-php-sdk","owner":"growingio","description":"GrowingIO PHP SDK","archived":false,"fork":false,"pushed_at":"2024-11-22T09:02:21.000Z","size":36,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":10,"default_branch":"op","last_synced_at":"2025-04-13T07:40:20.496Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/growingio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-26T01:35:09.000Z","updated_at":"2024-11-22T06:25:48.000Z","dependencies_parsed_at":"2024-11-09T16:16:52.539Z","dependency_job_id":"8c8a27f6-c854-4ed5-8de5-ed2feca2906d","html_url":"https://github.com/growingio/growingio-php-sdk","commit_stats":{"total_commits":18,"total_committers":3,"mean_commits":6.0,"dds":0.2222222222222222,"last_synced_commit":"e8f7eb006eff4c6de6698ed8f3ba7c442920cb0c"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/growingio%2Fgrowingio-php-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/growingio%2Fgrowingio-php-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/growingio%2Fgrowingio-php-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/growingio%2Fgrowingio-php-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/growingio","download_url":"https://codeload.github.com/growingio/growingio-php-sdk/tar.gz/refs/heads/op","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250002265,"owners_count":21359082,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T16:16:49.923Z","updated_at":"2025-04-21T05:32:02.698Z","avatar_url":"https://github.com/growingio.png","language":"PHP","readme":"# GrowingIO PHP SDK\n\nGrowingIO提供在Server端部署的PHP SDK,从而可以方便的进行事件上报等操作\n\n### 集成 \u0026 安装\n\nphp sdk已经发布在[Packagist](https://packagist.org/packages/growingio/php-sdk), 可以通过[Composer](https://getcomposer.org)进行安装\n\n```composer\n\"growingio/php-sdk\": \"1.0.3\"\n```\n\n```php\n\u003c?php\nuse com\\growingio\\GrowingIO;\n//Load Composer's autoloader\nrequire 'vendor/autoload.php';\n```\n\n如果没有使用Composer, 可以直接下载源代码到php配置中指定的include_path目录中, 并手动加载类文件\n\n```php\n\u003c?php\nuse com\\growingio\\GrowingIO;\n\ninclude_once 'path/src/GrowingIO.php'; // path为对应路径\n```\n\n### 初始化配置\n\n###### 初始化参数\n\n|参数|必选|类型|默认值|说明|\n|:----|:----|:----|:----|-----|\n|accountID|true|string| |项目 ID,见数据源配置|\n|host|true|string| |数据收集服务域名,请参考运维手册或联系技术支持获取|\n|dataSourceId|true|string| |数据源 ID,见数据源配置|\n|props|false|array|array()|初始化配置额外参数|\n\n###### 初始化配置额外参数\n\n|参数|必选|类型|默认值|说明|\n|:----|:----|:----|:----|-----|\n|debug|false|boolean|false|debug 模式, 此模式仅打印日志, 不发送数据|\n|idMappingEnabled|false|boolean|false|是否支持设置用户类型, false, 不发送userKey. true, 发送userKey|\n\n###### 示例\n\n```php\n$accountID = '1234567887654321';\n$host = 'https://localhost.com';\n$dataSourceId = '12345678';\n$props = array('debug' =\u003e true);\n\n$gio = GrowingIO::getInstance($accountID, $host, $dataSourceId, $props);\n```\n\n### 数据采集API\n\n**1\\. 采集自定义事件**\n\n###### 接口功能\n\n\u003e 发送一个自定义事件。在添加所需要发送的事件代码之前,需要在事件管理用户界面配置事件以及事件级变量\n\n###### 请求参数\n\n|参数|必选|类型|默认值|说明|\n|:----|:----|:----|:----|-----|\n|eventKey|true| string | |事件名, 事件标识符|\n|loginUserId|false| string |  |登录用户id，与匿名用户id不能同时为空|\n|anonymousId|false| string|  |匿名用户id，与登录用户id不能同时为空|\n|evnetTime|false|int|当前时间的时间戳|事件发生时间。如需要开启\"自定义event_time上报\"的功能开关，请联系技术支持|\n|loginUserKey|false|string| |登录用户类型|\n|properties|false|array|array()|事件发生时，所伴随的维度信息，1.0.3版本支持value为array|\n\n###### 示例\n\n```php\n$gio-\u003etrackCustomEvent($gio-\u003egetCustomEventFactory()\n    -\u003esetEventKey('event_name')\n    -\u003esetLoginUserId('loginUserId')\n    -\u003esetAnonymousId('anonymousId')\n    -\u003esetEventTime(1648524854000)\n    -\u003esetLoginUserKey('loginUserKey')\n    -\u003esetProperties(array('attrKey1' =\u003e 'attrValue1',\n        'attrKey2' =\u003e 'attrValue2',\n        'array' =\u003e array('1', '2', '3')))\n    -\u003ecreate()\n);\n```\n\n**2\\. 设置登录用户变量**\n\n###### 接口功能\n\n\u003e 以登录用户的身份定义用户属性变量,用于用户信息相关分析\n\n###### 请求参数\n\n|参数|必选|类型|默认值|说明|\n|:----|:----|:----|:----|-----|\n|loginUserId|false| string|  |登录用户id，与匿名用户id不能同时为空|\n|anonymousId|false| string|  |匿名用户id，与登录用户id不能同时为空|\n|properties|true|array| |用户属性信息，1.0.3版本支持value为array|\n|loginUserKey|false|string| |登录用户类型|\n\n###### 示例\n\n```php\n$gio-\u003esetUserAttributesEvent($gio-\u003egetUserAttributesFactory('loginUserId')\n    -\u003esetLoginUserId('loginUserId')\n    -\u003esetAnonymousId('anonymousId')\n    -\u003esetProperties(array('gender' =\u003e 'male',\n        'age' =\u003e '18',\n        'goods' =\u003e array('book', 'bag', 'lipstick')))\n    -\u003esetLoginUserKey('loginUserKey')\n    -\u003ecreate());\n```\n\n**3\\. 设置物品模型**\n\n###### 接口功能\n\n\u003e 上传物品模型\n\n###### 请求参数\n\n|参数|必选|类型|默认值|说明|\n|:----|:----|:----|:----|-----|\n|itemId|true|string| |物品模型id|\n|itemKey|true|string| |物品模型key|\n|properties|false|array|array()|物品模型属性信息|\n\n###### 示例\n\n```php\n$gio-\u003esetItemAttributes(\n    '1001',\n    'product',\n    array('color' =\u003e 'red')\n);\n```\n\n### 集成示例\n\n```php\n\u003c?php\nuse com\\growingio\\GrowingIO;\n\ninclude_once 'path/src/GrowingIO.php'; // path为对应路径\n\n// 请在您调试前,将accountID修改为您的项目AccountID\n// 所有自定义事件需要提前在GrowingIO产品中进行定义\n// 所有自定义事件的属性也需要提前在GrowingIO产品中进行定义\n$accountID = '1234567887654321';\n$host = 'https://localhost.com';\n$dataSourceId = '12345678';\n$props = array('debug' =\u003e true);\n$gio = GrowingIO::getInstance($accountID, $host, $dataSourceId, $props);\n\n// 采集自定义事件\n$gio-\u003etrackCustomEvent($gio-\u003egetCustomEventFactory()\n    -\u003esetEventKey('event_name')\n    -\u003esetLoginUserId('loginUserId')\n    -\u003esetAnonymousId('anonymousId')\n    -\u003esetEventTime(1648524854000)\n    -\u003esetLoginUserKey('loginUserKey')\n    -\u003esetProperties(array('attrKey1' =\u003e 'attrValue1',\n        'attrKey2' =\u003e 'attrValue2',\n        'array' =\u003e array('1', '2', '3')))\n    -\u003ecreate()\n);\n\n// 设置登录用户变量\n$gio-\u003esetUserAttributesEvent($gio-\u003egetUserAttributesFactory('loginUserId')\n    -\u003esetLoginUserId('loginUserId')\n    -\u003esetAnonymousId('anonymousId')\n    -\u003esetProperties(array('gender' =\u003e 'male',\n        'age' =\u003e '18',\n        'goods' =\u003e array('book', 'bag', 'lipstick')))\n    -\u003esetLoginUserKey('loginUserKey')\n    -\u003ecreate());\n\n// 设置物品模型\n$gio-\u003esetItemAttributes(\n    '1001',\n    'product',\n    array('color' =\u003e 'red')\n);\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrowingio%2Fgrowingio-php-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrowingio%2Fgrowingio-php-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrowingio%2Fgrowingio-php-sdk/lists"}