承接 kim/activity 相关项目开发

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

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

kim/activity

Composer 安装命令:

composer require kim/activity

包简介

Easily retrieve a list of users and guests that are online.

README 文档

README

With this package, you can easily see who's online and how many guests are viewing your site.

Installation

To install this package, just follow these quick few steps.

Composer

As always, pull this package through composer by opening composer.json file and adding this within require:

"kim/activity": "^1.1"

Note: If you are running Laravel 5.0 or 5.1, please require version "^1.0".

Afterward, run either composer update.

Providers and Aliases

Next, open config/app.php and add this to your providers array:

Kim\Activity\ActivityServiceProvider::class

and this to your aliases array:

'Activity' => Kim\Activity\ActivityFacade::class

Session and Database Setup

Finally, you need to change your session configuration to use the database. Open the .env file, which should be at the root directory of your Laravel project. Then, change your session driver to database.

SESSION_DRIVER=database

If you are running L5.2, publish the default session migrations file and then migrate it by running these commands:

php artisan session:table

php artisan migrate

If you are running L5.0 or L5.1, run these commands:

php artisan vendor:publish --provider="Kim\Activity\ActivityServiceProvider" --tag="migrations"

php artisan migrate

Usage

This package will automatically update a user's or guest's most recent activity. To grab the most recent users and guests though, you can use the easy-to-use built-in methods.

Grabbing Most Recent Activities

Import the Activity facade at the top and then do a simple query.

// Import at the top
use Activity;


// Find latest users
$activities = Activity::users()->get();

// Loop through and echo user's name
foreach ($activities as $activity) {
    echo $activity->user->name . '<br>';
}

The users method will grab the most recent activities within the past 5 minutes. You can change the default timespan by specifying the minutes.

$activities = Activity::users(1)->get();   // Last 1 minute
$activities = Activity::users(10)->get();  // Last 10 minutes
$activities = Activity::users(60)->get();  // Last 60 minutes

You have other methods for your convenience to grab the latest activities by seconds or even hours.

$activities = Activity::usersBySeconds(30)->get();  // Get active users within the last 30 seconds
$activities = Activity::usersByMinutes(10)->get();  // Get active users within the last 10 minutes
$activities = Activity::usersByHours(1)->get();     // Get active users within the last 1 hour

$numberOfUsers = Activity::users()->count();        // Count the number of active users

Sorting Methods

In order to sort the activities by most and least recent, just use the mostRecent and leastRecent methods.

$activities = Activity::users()->mostRecent()->get();   // Get active users and sort them by most recent
$activities = Activity::users()->leastRecent()->get();  // Get active users and sort them by least recent

In addition to this, you can sort the user's attributes by using the orderByUsers method. For example, rather than ordering by the most recent activity, lets say you want to order by the users' name alphabetically. You can do this.

$activities = Activity::users()->orderByUsers('email')->get();

Grabbing the Guests

In order to grab the number of guests that are online, it's just as intuitive as grabbing the users. For example:

$numberOfGuests = Activity::guests()->count();      // Count the number of active guests

License

This package is free software distributed under the terms of the MIT license.

kim/activity 适用场景与选型建议

kim/activity 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 30.49k 次下载、GitHub Stars 达 128, 最近一次更新时间为 2015 年 10 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「laravel」 「online activity」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 kim/activity 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 kim/activity 我们能提供哪些服务?
定制开发 / 二次开发

基于 kim/activity 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 128
  • Watchers: 10
  • Forks: 30
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-19