Contributing Guide

Hi! I'm really excited that you are interested in contributing to Fresns. Before submitting your contribution, please make sure to take a moment and read through the following guidelines:

Framework

FrameworkVersionUse
Composeropen in new window2.1.6application-level package manager
Laravel Frameworkopen in new window8.62.0Framework
Bootstrapopen in new window5.1.0Internal Front-end Framework
Bootstrap Iconsopen in new window1.5.0Internal Icon Font Library
jQueryopen in new window3.6.0Internal JS Framework
Base64 JSopen in new window3.6.1Internal Base64 Transcoder
VuePressopen in new window2.0.0Fresns Official Website Generator
DatabaseVersion
MySQL8.0.17
Collationutf8mb4_0900_ai_ci
Storage engineInnoDB
数据库版本说明

从 MySQL 8.0.17 版本开始,数字字段类型 tinyint, smallint, mediumint, int, bigint 如果属性设置为 UNSIGNED 时,不支持设置字段“长度”值。因此我们初始化数据结构已不再设置 UNSIGNED 属性数字字段的长度,所以开发环境建议 8.0.17 及以上版本。

协作规范

GuideVersion来源
12-factorsopen in new window2017Adam Wiggins
Conventional Commitsopen in new window1.0.0Conventional Commits
Semantic Versioningopen in new window2.0.0Gravatars
Docs Writing Guideopen in new window2021Vue.js

辅助工具

ToolDescription
StyleCIopen in new windowThe Web Coding Style Fixer
Sentryopen in new window程序性能监控服务,帮助 Fresns 诊断、修复和优化代码的性能
Huntropen in new window漏洞赏金平台,帮助 Fresns 发现安全问题

Coding Style

In order to keep the Fresns codebase clean and consistent, we have a number of coding style guidelines that we follow. When in doubt, read the source code.

Don't worry if your code styling isn't perfect! StyleCIopen in new window will automatically merge any style fixes into Fresns repositories after pull requests are merged. This allows us to focus on the content of the contribution and not the code style.

Fresns follows the PSR-2open in new window coding standard and the PSR-4open in new window autoloading standard. On top of this, we conform to a number of other style rules (opens new window). We use PHP 7 type hinting and return type declarations where possible, and PHPDocopen in new window to provide inline documentation. Try and mimic the style used by the rest of the codebase in your contributions.

  • Namespaces should be singular (eg. Fresns\Discussion, not Fresns\Discussions)
  • Interfaces should be suffixed with Interface (eg. MailableInterface)
  • Abstract classes should be prefixed with Abstract (eg. AbstractModel)
  • Traits should be suffixed with Trait (eg. ScopeVisibilityTrait)
  • "status" or "state"
    • status is used to describe an outcome of an operation (e.g. success/fail).
    • state is used to describe a stage in a process (e.g. pending/dispatched).

Database Style

Tables should be named as follows:

  • Use plural form (languages)
  • Separate multiple words with underscores (session_tokens)
  • For relationships tables, join the two table names in singular form with an underscore in alphabetical order (eg. discussion_user)

Columns should be named according to their data type:

  • DATETIME or TIMESTAMP: {verbed}_at (eg. created_at, read_at) or {verbed}_until (eg. suspended_until)
  • INT that is a count: {noun}_count (eg. comment_count, word_count)
  • Foreign key: {verbed}_{entity}_id (eg. hidden_user_id)
    • Verb can be omitted for primary relationship (eg. post author is just user_id)
  • BOOL: is_{adjective} (eg. is_locked)
  • 标志性时间值必须采用 TIMESTAMP 类型字段,确保支持时区请求(例如:创建时间、更新时间、操作行为时间)。
  • 颜色值字段统一存储为 6 位十六进制颜色值。

Contributor License Agreement

By contributing your code to Fresns you grant the Fresns Foundation (Stichting Fresns) a non-exclusive, irrevocable, worldwide, royalty-free, sublicensable, transferable license under all of Your relevant intellectual property rights (including copyright, patent, and any other rights), to use, copy, prepare derivative works of, distribute and publicly perform and display the Contributions on any licensing terms, including without limitation: (a) open source licenses like the MIT license; and (b) binary, proprietary, or commercial licenses. Except for the licenses granted herein, You reserve all right, title, and interest in and to the Contribution.

You confirm that you are able to grant us these rights. You represent that You are legally entitled to grant the above license. If Your employer has rights to intellectual property that You create, You represent that You have received permission to make the Contributions on behalf of that employer, or that Your employer has waived such rights for the Contributions.

You represent that the Contributions are Your original works of authorship, and to Your knowledge, no other person claims, or has the right to claim, any right in any invention or patent related to the Contributions. You also represent that You are not legally obligated, whether by entering into an agreement or otherwise, in any way that conflicts with the terms of this license.

The Fresns Foundation acknowledges that, except as explicitly described in this Agreement, any Contribution which you provide is on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.

/*
 * Fresns
 * Copyright (C) 2021-Present Jarvis Tang
 * Released under the Apache-2.0 License.
 */
1
2
3
4
5