fenos/rally
Composer 安装命令:
composer require fenos/rally
包简介
Followers system for laravel 4
关键字:
README 文档
README
Follow, Let Follow you, Follow with Rally. Rally is a plugin that implement in your application the follow system. It is quick to implement on your laravel project. It give you the freedom to create your own followers system. It is can be polymorphic, so you can follow anybody or anything you want. The package has been released for laravel 4.*
Installation
Step 1
Add it on your composer.json
"fenos/rally": "1.0.*"
and run composer update
Step 2
Add the following string to app/config/app.php
Providers array:
'Fenos\Rally\RallyServiceProvider'
Aliases array:
'Rally' => 'Fenos\Rally\Facades\Rally'
Step 3
Migration
Make sure that your settings on app/config/database.php are correct, then make the migration typing:
php artisan migrate --package="fenos/rally"
Step 4
Include relations
Rally comes with some relations already setted for you, you just need to insert the trait that I made for you in all your models you wish to have relations with Rally.
class User extends Eloquent
{
use \Fenos\Rally\Models\Relations;
}
That's it your have done.
Documentation
How i said on the installation, Rally can be Polymorphic, it means that if you have Users and Teams as entity of your application they can follow between them. But it is just up to you. If you realize that
you don't need of it, You can keep it as a single model binding.
The key to enable or disable the polymorphic relation is in the configuration files. You just need to push them and change the key polymorphic to true.
if instead you want to keep the plugin as 1 model but the User model is not your main model change it ;)
php artisan config:publish fenos/rally
Follow
For start to be followers of a entity when it comes polymorphically you will use the following method let me show you.
try
{
Rally::follower('User',$user_id)->follow('Team',$team_id);
}
catch(\Fenos\Rally\Exceptions\AlreadyFollowerException $e)
{
// is already fan
}
With only fews line of code the user has started to follow the team.
If instead you use Rally as normal
try
{
Rally::follower($user_id)->follow($user_id);
}
catch(\Fenos\Rally\Exceptions\AlreadyFollowerException $e)
{
// is already follower
}
Let me explain it. The method follower() specify the user that want to be follower, so if Rally comes polymorphically you have to specify as
first paramter The model of it, as second parameter the id if instead is not polymorphically just the ID.
Almost same the method follow() in this method you specify who will be followed parameters are same.
UnFollow
If you don't want follow someone anymore you will use this method:
Polymorphically
try
{
Rally::follower('User',$user_id)->unFollow('Team',$team_id);
}
catch(\Fenos\Rally\Exceptions\FollowerNotFoundException $e)
{
// the user already doesn't follow him
}
Normal
try
{
Rally::follower($user_id)->unFollow($user_id);
}
catch(\Fenos\Rally\Exceptions\FollowerNotFoundException $e)
{
// the user already doesn't follow him
}
Check if Is follow of
If you want to know a given User if has following someone use:
Polymorphically
Rally::follower('User',$user_id)->isFollowerOf('Team',$team_id);
Normal
Rally::follower($user_id)->isFollowerOf($user_id); // return Boolean
Get lists of followers
Well Rally give to you a easy way to get the lists of your followers but remeber that you implemented the trait with the relations
in your model, So you can even access to them directly from that, I suggest that. But let me show you if you want use Rally.
Polymorphically
Rally::follower('User',$user_id)->getLists();
Rally::follower('User',$user_id)->getLists(['orderBy' => 'DESC', 'limit' => 10]);
Rally::follower('User',$user_id)->getLists(['orderBy' => 'DESC', 'paginate' => 5 ]);
Normal
Rally::follower($user_id)->getLists();
Rally::follower($user_id)->getLists(['orderBy' => 'DESC', 'limit' => 10]);
Rally::follower($user_id)->getLists(['orderBy' => 'DESC', 'paginate' => 5 ]);
You can even chain count() it return a Collection so you can use all the methods of it.
Count Followers
You Need just the numbers of followers and nothing else?
Polymorphically
Rally::follower('User',$user_id)->count();
Normal
Rally::follower($user_id)->count();
I hope you'll enjoy it.
Note
I made it with <3
Tests
For run the tests make sure to have phpUnit and Mockery installed
Credits
© Copyright Fabrizio Fenoglio
Released package under MIT Licence.
fenos/rally 适用场景与选型建议
fenos/rally 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 227 次下载、GitHub Stars 达 37, 最近一次更新时间为 2014 年 05 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「Follow」 「Followers」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 fenos/rally 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fenos/rally 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 fenos/rally 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Eloquent Befriended brings social media-like features like following, blocking and filtering content based on following or blocked models.
This package gives Eloquent models the ability to manage their followers.
Follow, Favourite, Bookmark, Like & Subscribe.
Displays a list of tags that the user is following in the sidebar.
Let users follow other users and elements (Categories, Tags etc) to generate lists & feeds.
Build a poly-morph Follower system or simply associate Eloquent models in Laravel 5.
统计信息
- 总下载量: 227
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 37
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-05-14