承接 lunacms/forums 相关项目开发

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

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

lunacms/forums

Composer 安装命令:

composer require lunacms/forums

包简介

Forums for your laravel app

README 文档

README

Latest Version on Packagist Total Downloads GitHub Actions

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

  • CanCommentTrait for model to post, update, reply or delete comments.
  • OwnsForumTrait for 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 forum CRUD operations.
  • PostRepository: handles basic post CRUD operations.
  • TagRepository: handles basic tag CRUD operations.
  • CommentRepository: handles basic comment CRUD operations.

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 is web
  • auth_middleware: Used for authenticating users who create forums, posts and comments. Default is auth.

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 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2023-02-18