lunacms/forums
Composer 安装命令:
composer require lunacms/forums
包简介
Forums for your laravel app
README 文档
README
An API first forums package that allows running a single forum or multiple forums within your Laravel app. Supports Laravel 8 and above.
Installation
You can install the package via composer:
composer require lunacms/forums
You
Then run migrate command:
php artisan migrate
Configuration
To customize the package usage, copy the package config to your local config by using the publish command:
php artisan vendor:publish --tag=forums-config
You can configure your models, resources and morph map (for polymorphic relationships) there.
Usage
Traits
CanCommentTraitfor model to post, update, reply or delete comments.OwnsForumTraitfor model to own a forum.
Add both traits to your User model.
By default the package uses the authenticated request user as owner of forum, posts and comments.
Running in Single Mode
Set mode option value to single in config/forums.php.
mode='single'
Call runInSingleMode() in boot method of AppServiceProvider.
Forums::runInSingleMode();
Model Repositories
The package offers model repositories to enable interaction with the underlying API.
Included repositories are:
ForumRepository: handles basic forumCRUDoperations.PostRepository: handles basic postCRUDoperations.TagRepository: handles basic tagCRUDoperations.CommentRepository: handles basic commentCRUDoperations.
Available methods:
all(): Get all records for a given entity.find($id): Find a record by given "id".findWhere($column, $value): Find records by given "column" value.findWhereFirst($column, $value): Find the first record with given "column" value.paginate($perPage = 10): Paginate records for a given entity.create(array $data): Create a record for a given entity.update($id, array $data): Update a record of a given entity.delete($id): Delete a record from an entity.withCriteria(...$criteria): Refines a repository's query.
Repositories can be used if you need to interact more deeply with the API.
Routes
By default we have setup routes as the easiest way to use the package.
Note: The enclosed {CUSTOM_PREFIX} is a prefix which can be changed in the forums config
route prefix.
Securing Routes
You can secure the package routes by setting the relevant middleware in the config file, under routes settings.
There are two options:
middleware: Key used to set the general routing and bindings, default iswebauth_middleware: Used for authenticating users who create forums, posts and comments. Default isauth.
Comment Routes
They accept an id as parameter and body in the request data (except destroy) route.
-
{CUSTOM_PREFIX}/comments/{comment}: Handle comment update;PUT|PATCH -
{CUSTOM_PREFIX}/comments/{comment}: Handle comment destroy;DELETE -
{CUSTOM_PREFIX}/comments/{comment}/replies: Handle comment reply store;POST
Forums Routes
Handles forum functionality when mode is multi.
For post and put|patch routes, a name is required, and optional tags array.
When displaying, updating, or deleting a slug is passed as route param.
-
{CUSTOM_PREFIX}/forums: Handles forums listing;GET|HEAD -
{CUSTOM_PREFIX}/forums: Handles forum storage;POST -
{CUSTOM_PREFIX}/forums/{slug}: Handles showing single forum data;GET|HEAD -
{CUSTOM_PREFIX}/forums/{slug}: Handles forum update;PUT|PATCH -
{CUSTOM_PREFIX}/forums/{slug}: Handles forum destroy;DELETE
Posts Routes (in multi mode)
Pass forum slug as route param for all routes below: ie replace forums:slug.
An additional slug required for the single post display route, use $post->slug
-
{CUSTOM_PREFIX}/forums/{forum:slug}/posts: Handles a forums posts listing;GET|HEAD -
{CUSTOM_PREFIX}/forums/{forum:slug}/posts: Handles a forums post storage;POST -
{CUSTOM_PREFIX}/forums/{forum:slug}/posts/{slug}: Handles showing of a single post in a forum;GET|HEAD
Posts Route (in single mode)
Post slug required for a single post display route.
-
{CUSTOM_PREFIX}/posts: Handles a posts listing;GET|HEAD -
{CUSTOM_PREFIX}/posts: Handles a post storage;POST -
{CUSTOM_PREFIX}/posts/{slug}: Handles a showing of a forums post;GET|HEAD
Posts Routes (shared in both modes)
Post slug as route param.
-
{CUSTOM_PREFIX}/posts/{slug}: Handle post update;PUT|PATCH -
{CUSTOM_PREFIX}/posts/{slug}: Handle post delete;DELETE
Post Comment Routes (shared in both modes)
Post slug as route param; body passed as request data for POST route.
-
{CUSTOM_PREFIX}/posts/{slug}/comments: Handle listing a post's comments;GET|HEAD -
{CUSTOM_PREFIX}/posts/{slug}/comments: Handle creating a post's comment;POST
Tags
Use slug as route params for all routes except index and store.
Pass name as request data for POST and PATCH routes.
-
{CUSTOM_PREFIX}/tags: Handles tags listing;GET|HEAD -
{CUSTOM_PREFIX}/tags: Handles tags store;POST -
{CUSTOM_PREFIX}/tags/{tag}: Handles single tag display;GET|HEAD -
{CUSTOM_PREFIX}/tags/{tag}: Handles tag update;PUT|PATCH -
{CUSTOM_PREFIX}/tags/{tag}: Handles tag destroy;DELETE
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email miracuthbert@gmail.com instead of using the issue tracker.
Credits
License
The GNU GPLv3. Please see License File for more information.
lunacms/forums 适用场景与选型建议
lunacms/forums 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 2, 最近一次更新时间为 2023 年 02 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「forums」 「lunacms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 lunacms/forums 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lunacms/forums 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 lunacms/forums 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Provides a standard password hashing interface and support for password hashing in common frameworks.
Provides support for legacy password hashing in common frameworks.
Single Sign On plugin for Vanilla Forums/jsConnect and CraftCMS
Forums for Anahita Social Platform
Forums addon for Bear CMS
LunaCMS is a lightweight and high-performance content management system.
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2023-02-18