|
| 1 | +# Contributing |
| 2 | + |
| 3 | +Thank you for considering contributing to Symfony UX! |
| 4 | + |
| 5 | +Symfony UX is an open source, community-driven project, and we are happy to receive contributions from the community! |
| 6 | + |
| 7 | +> [!TIP] |
| 8 | +> It's a good idea to read the [Symfony's Contribution Guide](https://symfony.com/doc/current/contributing/index.html) first, even if not all of it applies to Symfony UX and should be adapted to this project (e.g.: Symfony UX has only one base branch, `2.x`). |
| 9 | +
|
| 10 | +## Reporting an issue |
| 11 | + |
| 12 | +If you either find a bug, have a feature request, or need help/have a question, please [open an issue](https://github.com/symfony/ux/issues/new/choose). |
| 13 | + |
| 14 | +Please provide as much information as possible, |
| 15 | +and remember to follow our [Code of Conduct](https://symfony.com/doc/current/contributing/code_of_conduct/index.html) |
| 16 | +as well, to ensure a friendly environment for all contributors. |
| 17 | + |
| 18 | +## Contributing to the code and documentation |
| 19 | + |
| 20 | +Thanks for your interest in contributing to Symfony UX! Here are some guidelines to help you get started. |
| 21 | + |
| 22 | +### Forking the repository |
| 23 | + |
| 24 | +To contribute to Symfony UX, you need to [fork the **symfony/ux** repository](https://github.com/symfony/ux/fork) on GitHub. |
| 25 | +This will give you a copy of the code under your GitHub user account, read [the documentation "How to fork a repository"](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo). |
| 26 | + |
| 27 | +After forking the repository, you can clone it to your local machine: |
| 28 | + |
| 29 | +```shell |
| 30 | +$ git clone [email protected]: <USERNAME >/symfony-ux.git symfony-ux |
| 31 | +$ cd symfony-ux |
| 32 | +# Add the upstream repository, to keep your fork up-to-date |
| 33 | +$ git remote add upstream [email protected]:symfony/ux.git |
| 34 | +``` |
| 35 | + |
| 36 | +### Setting up the development environment |
| 37 | + |
| 38 | +To set up the development environment, you need the following tools: |
| 39 | + |
| 40 | +- [PHP](https://www.php.net/downloads.php) 8.1 or higher |
| 41 | +- [Composer](https://getcomposer.org/download/) |
| 42 | +- [Node.js](https://nodejs.org/en/download/package-manager) 22 or higher |
| 43 | +- [Yarn](https://yarnpkg.com/) 4 or higher |
| 44 | + |
| 45 | +With these tools installed, you can install the project dependencies: |
| 46 | + |
| 47 | +```shell |
| 48 | +$ composer install |
| 49 | +$ corepack enable && yarn install |
| 50 | +``` |
| 51 | + |
| 52 | +### Linking Symfony UX packages to your project |
| 53 | + |
| 54 | +If you want to test your code in an existing project that uses Symfony UX packages, |
| 55 | +you can use the `link` utility provided in this Git repository (that you have to clone). |
| 56 | + |
| 57 | +This tool scans the `vendor/` directory of your project, finds Symfony UX packages it uses, |
| 58 | +and replaces them by symbolic links to the ones in the Git repository. |
| 59 | + |
| 60 | +```shell |
| 61 | +$ php link /path/to/your/project |
| 62 | +``` |
| 63 | + |
| 64 | +### Working with PHP code |
| 65 | + |
| 66 | +Symfony UX follows Symfony [PHP coding standards](https://symfony.com/doc/current/contributing/code/standards.html) |
| 67 | +and [the Backward Compatibility Promise](https://symfony.com/doc/current/contributing/code/bc.html). |
| 68 | + |
| 69 | +When contributing, please make sure to follow these standards and to write tests for your code, |
| 70 | +runnable with `php vendor/bin/simple-phpunit`. |
| 71 | + |
| 72 | +### Working with assets |
| 73 | + |
| 74 | +Assets are specific to each Symfony UX package: |
| 75 | + - They are located in the `assets/` directory of each package, and can be either TypeScript or CSS files, respectively compiled through Rollup and PostCSS, |
| 76 | + - Assets are mentioned in the `package.json` file of each package, |
| 77 | + - Assets **must be** compiled before committing changes, |
| 78 | + - Assets **must be** compatible with the [Symfony AssetMapper](https://symfony.com/doc/current/frontend/asset_mapper.html) and [Symfony Webpack Encore](https://symfony.com/doc/current/frontend/encore/index.html). |
| 79 | + |
| 80 | +To help you with assets, you can run the following commands in a specific package directory (e.g., `src/Map/assets/`): |
| 81 | + - `yarn run build`: build (compile) assets from the package, |
| 82 | + - `yarn run watch`: watch for modifications and rebuild assets from the package, |
| 83 | + - `yarn run test`: run the tests from the package, |
| 84 | + - `yarn run lint`: lint assets from the package, |
| 85 | + - `yarn run format`: format assets from the package. |
| 86 | + |
| 87 | +Thanks to [Yarn Workspaces](https://yarnpkg.com/features/workspaces), you can also run these commands from the root directory of the project: |
| 88 | + - `yarn run build`: build (compile) assets from **all** packages, |
| 89 | + - `yarn run test`: run the tests from **all** packages, |
| 90 | + - `yarn run lint`: lint assets from **all** packages, |
| 91 | + - `yarn run format`: format assets from **all** packages, |
| 92 | + |
| 93 | +## Useful Git commands |
| 94 | + |
| 95 | +1. To keep your fork up-to-date with the upstream repository and `2.x` branch, you can run the following commands: |
| 96 | +```shell |
| 97 | +$ git checkout 2.x && \ |
| 98 | + git fetch upstream && \ |
| 99 | + git rebase upstream/2.x && \ |
| 100 | + git push origin 2.x |
| 101 | +``` |
| 102 | + |
| 103 | +2. To rebase your branch on top of the `2.x` branch, you can run the following commands: |
| 104 | +```shell |
| 105 | +$ git checkout my-feature-branch && \ |
| 106 | + git rebase upstream/2.x && \ |
| 107 | + git push -u origin my-feature-branch |
| 108 | +``` |
0 commit comments