承接 regulus/activity-log 相关项目开发

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

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

regulus/activity-log

Composer 安装命令:

composer require regulus/activity-log

包简介

A clean and simple Laravel 5 activity logger for monitoring user activity on a website or web application.

README 文档

README

A simple and clean Laravel 5 activity logger for monitoring user activity on a website or web application.

Installation

Basic installation, service provider registration, and aliasing:

To install ActivityLog, make sure "regulus/activity-log" has been added to Laravel 5's composer.json file.

"require": {
	"regulus/activity-log": "0.6.*"
},

Then run php composer.phar update from the command line. Composer will install the ActivityLog package. Now, all you have to do is register the service provider and set up ActivityLog's alias. In app/config/app.php, add this to the providers array:

Regulus\ActivityLog\ActivityLogServiceProvider::class,

And add this to the aliases array:

'Activity' => Regulus\ActivityLog\Models\Activity::class,

Publishing migrations and configuration:

To publish this package's configuration and migrations, run this from the command line:

php artisan vendor:publish

You will now be able to edit the config file in config/log.php if you wish to customize the configuration of ActivityLog.

Note: Migrations are only published; remember to run them when ready.

To run migration to create ActivityLog's table, run this from the command line:

php artisan migrate

Basic Usage

Logging user activity:

	Activity::log([
		'contentId'   => $user->id,
		'contentType' => 'User',
		'action'      => 'Create',
		'description' => 'Created a User',
		'details'     => 'Username: '.$user->username,
		'updated'     => (bool) $id,
	]);

The above code will log an activity for the currently logged in user. The IP address will automatically be saved as well and the developer flag will be set if the user has a developer session variable set to true. This can be used to differentiate activities between the developer and the website administrator. The updated boolean, if set to true, will replace all instances of "Create" or "Add" with "Update" in the description and details fields.

Advanced Usage

As of version 0.6.0, ActivityLog has built in the ability to dynamically create descriptions based on language keys in Laravel's language files. If you would like to enable this feature without having to set language_key to true when you use the log() function, change defaults.language_key to true in the config file (it is not present by default so you will have to add it).

Logging user activity with language keys:

	Activity::log([
		'contentType' => 'Record',
		'description' => [
			'created_items', [ // "activity-log::descriptions.created_items" is ":user created :number :items."
				'number' => 2,
				'items'  => 'SPL|labels.record', // "labels.record" in this example has a string of "Record|Records"
			],
		],
		'details' => [
			'record',
			'This is Some Kind of Record',
		],
		'data' => [
			'category' => 'Content',
		],
	]);

	echo $activity->getDescription(); // may output "Unknown User created 2 records."

	echo $activity->getDetails(); // may output "Record: This is Some Kind of Record"

	echo $activity->getData('category'); // will output "Content"

In the example above, the items replacement variable in the description has a number of specified properties before the | character which separates them from the actual language variable. The available properties are as follows:

S - Return the "singular" string (in the case of "labels.record", "Record")
P - Return the "plural" string (in the case of "labels.record", "Records")
A - Prepend the string with "a" or "an" (example: "a record" instead of just "record")
L - Convert the string to lowercase

In our example above, you will see both singular ("S") and plural ("P") are being used. When both are used, the description builder looks for a number replacement variable to decide whether the singular or plural form should be used.

Note: The user replacement variable is automatically set based on the record's user ID.

Getting Linked Content

Set up the content_types config array like the following example:

	'item' => [
		'uri'       => 'view/:id',
		'subdomain' => 'items',
		'model'     => 'App\Models\Item',
	],

You can use getContentItem() to get the item based on the specified model (assuming, in the case of the above specified example, that your content type is set to "Item"). You can also use getUrl() to get the URL of the content item or getLinkedDescription() to get a linked description for the item.

Displaying Action Icons

Display an action icon based on config setup:

	echo $activity->getIconMarkup();

You can also use getIcon() to get just the icon class from which to build your own icon markup.

regulus/activity-log 适用场景与选型建议

regulus/activity-log 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 223.75k 次下载、GitHub Stars 达 164, 最近一次更新时间为 2013 年 09 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 223.75k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 168
  • 点击次数: 22
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 164
  • Watchers: 10
  • Forks: 39
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-09-13