kakaprodo/murugo-analytic-helper
Composer 安装命令:
composer require kakaprodo/murugo-analytic-helper
包简介
A laravel package that lets you interact with murugo analytic APIs
README 文档
README
A laravel package that lets you interact with murugo analytic APIs
Package Installation
composer require kakaprodo/murugo-analytic-helper
Publish config file
php artisan murugo-analytic-helper:install
The config file will be published to your /config folder
Setup the .env file
Based on the enviroment in the config file you can define env variables
Activable Features
Use the MurugoAnalyticHelper::features() service gate to interact with activable features that you have registered on your Murugo Analytic account.
.env file requirement
You should define the following variables in your .env file
MURUGO_ANALYTIC_BASE_URL="https://analytics.murugo.cloud" MURUGO_ANALYTIC_ENVIRONMENT_UUID="environment-uuid"
Fetch all available features
Use the following example to retrieve all activable features configured for the current environment:
use Kakaprodo\MurugoAnalyticHelper\MurugoAnalyticHelper; use RuntimeException; $responseData = MurugoAnalyticHelper::features()->all(); if (! $responseData->isOk()) { throw new RuntimeException($responseData->getErrorMessage()); } $features = $responseData->features;
The features will be fetched at once and stored in your caching store for 1hour(you may change this in the config file).
The feature's all method support additional parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
email |
string |
null |
Optional email address used to check whether the user is on a feature's waiting list. If the email is found, the corresponding feature will be activated for that specific user (subject to the feature configuration). |
force |
bool |
false |
When set to true, bypasses the cached feature list and fetches the latest features directly from the Murugo Analytic API. |
use Kakaprodo\MurugoAnalyticHelper\MurugoAnalyticHelper; use RuntimeException; $responseData = MurugoAnalyticHelper::features()->all([ 'email' => 'kakaprodo@gmail.com', 'force' => true ]); if (! $responseData->isOk()) { throw new RuntimeException($responseData->getErrorMessage()); }
Get a specific feature
$featureData = $responseData->getFeature($featureKey); // return \Kakaprodo\MurugoAnalyticHelper\Services\Features\ResponseData\Partial\ActivatedFeatureData
getFeature() returns the matching feature when it exists, or null when the feature key is not found.
Check feature access
$canAccess = $responseData->canAccessFeature($featureKey);
canAccessFeature() returns a boolean:
truewhen the feature is accessible.falsewhen the feature is unavailable, inactive, locked, or inaccessible to the current user.
Error handling
Check the response with isOk() before using the data. When the request fails, call getErrorMessage() and throw a standard PHP exception or handle the error in your application flow.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-14