Saltar al contenido principal
Version: 1.x

Contribuir

¿Estás interesado en contribuir al desarrollo de Flarum? That's great! ¡Genial! Desde abrir un informe de error hasta crear un pull request: toda contribución es apreciada y bienvenida. Flarum wouldn't be possible without our community contributions.

Antes de contribuir, por favor lee el código de conducta.

Este documento es una guía para los desarrolladores que quieren contribuir con código a Flarum. Si estás empezando, te recomendamos que leas la documentación de Cómo Empezar en los documentos de Extensión para entender un poco más cómo funciona Flarum.

En qué trabajar

Have Real Impact. There are thousands of Flarum instances, with millions of aggregate end users. By contributing to Flarum, your code will have a positive impact on all of them.

🔮 Shape the Future of Flarum. We have a long backlog, and limited time. If you're willing to champion a feature or change, it's much more likely to happen, and you'll be able to enact your vision for it. Plus, our roadmap and milestones are set by our core development team, and all of us started as contributors. The best road to influence is contributing.

🧑‍💻 Become a Better Engineer. Our codebase is modern, and we heavily value good engineering and clean code. There's also a lot of interesting, challenging problems to solve regarding design, infrastructure, performance, and extensibility. Especially if you're a student or early in your career, working on Flarum is a great opportunity to build development skills.

🎠 It's Fun! We really enjoy working on Flarum: there's a lot of interesting challenges and fun features to build. We also have an active community on our forums and Discord server.

Configuración de desarrollo

Consulta nuestros próximos Hitos para tener una visión general de lo que hay que hacer. Consulta la etiqueta Good first issue para ver una lista de temas que deberían ser relativamente fáciles de empezar. If there's anything you're unsure of, don't hesitate to ask! All of us were just starting out once.

Si estás planeando seguir adelante y trabajar en algo, por favor comenta en el tema correspondiente o primero crea uno nuevo. De esta manera podemos asegurarnos de que tu precioso trabajo no sea en vano.

Since Flarum is so extension-driven, we highly recommend our extension docs as a reference when working on core, as well as for bundled extensions. You should start with the introduction for a better understanding of our extension philosophy.

Flujo de desarrollo

Setting Up a Local Codebase

flarum/flarum is a "skeleton" application which uses Composer to download the core package and a bunch of extensions. Source code for Flarum core, extensions, and all packages used by the aforementioned is located in the Flarum monorepo flarum/framework. In order to contribute to these, you'll need to fork and clone the monorepo repository locally, and then add it to your dev environment as a Composer path repository:

git clone https://github.com/flarum/flarum.git
cd flarum

# Or, when you want to clone directly into the current directory
git clone https://github.com/flarum/flarum.git .
# Note, the directory must be empty

# Set up a Composer path repository for Flarum monorepo packages
composer config repositories.0 path "PATH_TO_MONOREPO/*/*"
git clone https://github.com/<username>/framework.git PATH_TO_MONOREPO

Un flujo de trabajo de contribución típico es el siguiente:

Finalmente, ejecute composer install para completar la instalación desde los repositorios de la ruta.

Una vez que su instalación local esté configurada, asegúrese de que ha habilitado el modo debug en config.php, y establezca display_errors a On en su configuración php. Esto le permitirá ver los detalles de los errores tanto de Flarum como de PHP. Debug mode also forces a re-compilation of Flarum's asset files on each request, removing the need to call php flarum cache:clear after each change to the extension's JavaScript or CSS.

El código del front-end de Flarum está escrito en ES6 y transpilado en JavaScript. During development you will need to recompile the JavaScript using Node.js and yarn. Please do not commit the resulting dist files when sending PRs; this is automatically taken care of when changes are merged into the main branch.

To contribute to the frontend, first install the JavaScript dependencies. The monorepo uses yarn workspaces to easily install JS dependencies across all packages within.

cd packages/framework
yarn install

Then you can watch JavaScript files for changes during development:

cd framework/core/js
yarn dev

The process is the same for extensions.

cd extensions/tags/js
yarn dev

Development Tools

After you've forked and cloned the repositories you'll be working on, you'll need to set up local hosting so you can test out your changes. Flarum doesn't currently come with a development server, so you'll need to set up Apache/NGINX/Caddy/etc to serve this local Flarum installation.

Alternatively, you can use tools like, Laravel Valet (Mac), XAMPP (Windows), or Docker-Flarum (Linux) to serve a local forum.

Most Flarum contributors develop with PHPStorm or Visual Studio Code.

Estilo de Codificación

A typical contribution workflow looks like this:

  1. 🌳 Se bifurca el Branch apropiado en un nuevo branch de características.

    • Correcciones de Bugs debe enviarse al ultimo branch estable.
    • Características menores que son totalmente compatibles con la versión actual de Flarum pueden ser enviadas al ultimo branch estable.
  2. 🔨 Escribe algo de código.

    • Ver abajo sobre el Estilo de codificación.
    • Características mayores deben enviarse siempre al branch master, que contiene la próxima versión de Flarum.
    • Major features should always be sent to the main branch, which contains the upcoming Flarum release.
    • Internamente utilizamos el scheme de nomenclatura <initials>/<short-description> (eg. tz/refactor-frontend).
  3. 🚦 Prueba el código.

    • Añade pruebas unitarias según sea necesario cuando arregles errores o añadas características.
  4. 💾 Haz el commit de su código con un mensaje descriptivo.

    • Si su cambio resuelve un problema existente (por lo general, debería) incluir "Fixes #123" en una nueva línea, donde 123 es el número del issue.
    • Escriba un buen mensaje en el commit.
    • See here for more information about testing in Flarum.
  5. 🎁 Envia un Pull Request en GitHub.

    • Rellene la plantilla del pull request.
    • Follow the Conventional Commits specification.
    • Fix commits should describe the issue fixed, not how it was fixed.
  6. 🤝 Intercambio con el equipo de Flarum para su aprobación.

    • Fill out the pull request template.
    • Cuando se aborda la retroalimentación, envíe commits adicionales en lugar de sobrescribir o aplastar (vamos a aplastar en la fusión).
    • NO registre los archivos dist de JavaScript. Éstos se compilarán automáticamente en el merge.
  7. 🕺 Baila como si acabaras de contribuir a Flarum.

    • Los miembros del equipo revisarán su código. Podemos sugerir algunos cambios o mejoras o alternativas, pero para los pequeños cambios su pull request debería ser aceptado rápidamente.
    • When addressing feedback, push additional commits instead of overwriting or squashing (we will squash on merge).
  8. Columnas deben nombrarse según su tipo de datos:

Herramientas de Desarrollo

In order to keep the Flarum 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! StyleCI and Prettier will automatically check formatting for every pull request. This allows us to focus on the content of the contribution, not the code style.

PHP

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

  • Los espacios de nombres deben ser singulares (p. ej. Flarum-Discussion, no Flarum-Discussions).
  • Las interfaces deben llevar el sufijo Interface (p. ej. MailableInterface)
  • Las clases abstractas deben llevar el prefijo Abstract (p. ej. AbstractModel)
  • Los rasgos deben llevar el sufijo Trait (p. ej. ScopeVisibilityTrait)

JavaScript

Flarum's JavaScript mostly follows the Airbnb Style Guide. We use ESDoc to provide inline documentation.

Traducciones

Columns should be named according to their data type:

  • DATETIME o TIMESTAMP: {verbed}_at (ej. created_at, read_at) o {verbed}_until (ej. suspended_until)
  • INT que es un recuento: {noun}_count (ej. comment_count, word_count)
  • Clave foránea: {verbed}_{entity}_id (ej. hidden_user_id)
    • Se puede omitir el término para la relación primaria (por ejemplo, el autor del post es sólo user_id)
  • BOOL: is_{adjective} (ej. is_locked)

Tables should be named as follows:

  • Utilizar la forma plural (discussions)
  • Separe las palabras múltiples con guiones bajos (access_tokens)
  • Para las tablas de relaciones, unir los dos nombres de las tablas en singular con un guión bajo en orden alfabético (ej. discussion_user)

CSS

Flarum's CSS classes roughly follow the SUIT CSS naming conventions using the format .ComponentName-descendentName--modifierName.

Translations

We use a standard key format to name translation keys descriptively and consistently.

Acuerdo de Licencia para Colaboradores

By contributing your code to Flarum you grant the Flarum Foundation (Stichting Flarum) 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 Flarum 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.