Thank you for considering contributing to Symfony UX!
Symfony UX is an open source, community-driven project, and we are happy to receive contributions from the community!
Tip
It's a good idea to read the Symfony's Contribution Guide first
If you find a bug, have a feature request, or need help/have a question, please open an issue.
Please provide as much information as possible, and remember to follow our Code of Conduct to ensure a friendly environment for all contributors.
Thanks for your interest in contributing to Symfony UX! Here are some guidelines to help you get started.
To contribute to Symfony UX, you need to fork the symfony/ux repository on GitHub. This will give you a copy of the code under your GitHub user account. Read the documentation "How to fork a repository".
After forking the repository, you can clone it to your local machine:
# With GitHub CLI https://cli.github.com/
$ gh repo clone <USERNAME>/symfony-ux symfony-ux
# Using SSH
$ git clone git@github.com:<USERNAME>/symfony-ux.git symfony-ux
$ cd symfony-ux
# Add the upstream repository, to keep your fork up-to-date
$ git remote add upstream git@github.com:symfony/ux.gitTo set up the development environment, you need the following tools:
- PHP 8.1 or higher - Required for running Symfony components
- Composer - PHP dependency manager
- Node.js 22.18 or higher - Required for asset compilation
- Corepack - Package manager manager (comes with Node.js 16+)
- PNPM 10.16.1 or higher - JavaScript package manager (installed via Corepack)
With these tools installed, you can install the project dependencies:
# Install root PHP dependencies
$ composer install
# Enable PNPM through Corepack, and install JavaScript dependencies
$ corepack enable && pnpm installIf you want to test your code in an existing project that uses Symfony UX packages,
you can use the link utility provided in this Git repository (that you have to clone).
This tool scans the vendor/ directory of your project, finds Symfony UX packages it uses,
and replaces them by symbolic links to the ones in the Git repository.
$ php link /path/to/your/projectSymfony UX follows Symfony PHP coding standards and the Backward Compatibility Promise.
When contributing, please make sure to follow these standards and to write tests for your code,
runnable with php vendor/bin/simple-phpunit.
If you make changes to a component template or add a new one, create or update the EXAMPLES.md of the component. Then, you can (re)generate new snapshots by running:
php vendor/bin/simple-phpunit -d --update-snapshotsImportant
Snapshots will not reflect changes if you forget to update the EXAMPLES.md.
Assets are specific to each Symfony UX package:
- They are located in the
assets/directory of each package and can be either TypeScript or CSS files, all compiled through tsup - Assets are mentioned in the
package.jsonfile of each package - Assets must be compiled before committing changes
- Assets must be compatible with the Symfony AssetMapper and Symfony Webpack Encore
To help you with assets, you can run the following commands in a specific package directory (e.g., src/Map/assets/):
pnpm run build: build (compile) assets from the packagepnpm run watch: watch for modifications and rebuild assets from the packagepnpm run test: run the tests from the packagepnpm run test:unit: run the unit tests from the packagepnpm run test:browser: run the browser tests from the package in a headless browserpnpm run test:browser:ui: run the browser tests from the package in interactive mode, allowing you to see the tests running in a browser window and debug them if needed
Thanks to PNPM Workspaces, you can also run these commands from the root directory of the project:
pnpm run build: build (compile) assets from all packagespnpm run test: run the tests from all packagespnpm run test:unit: run the unit tests from all packagespnpm run test:browser: run the browser tests from all packages in a headless browserpnpm run fmt:check: run the code formatter for all packages, and fail if any modifications are neededpnpm run fmt: run the code formatter for all packages, and write modificationspnpm run lint: run the linter for all packagespnpm run lint:fix: run the linter for all packages, and fix any fixable issues
Important
Always run pnpm run build before committing your changes to ensure assets are properly compiled.
We use Vitest for unit testing of the assets,
and test files are located in the assets/test/unit/ directory of each UX package,
for example: src/Vue/assets/test/unit/render_controller.test.ts.
Running tests:
- At the project's root, you can run the following commands:
pnpm run test:unit: runs the unit tests for all UX packages
- Inside the
assets/directory of each UX package, you can run the following commands:pnpm run test:unit: runs the unit tests for the package
Important
The command pnpm run test:unit ensures that each possible combination of dependencies is tested
(e.g., "chart.js": "^3.4.1 || ^4.0" for UX Chartjs).
Thus it may take some time to run, and we don't recommend using watch mode.
Note
E2E tests simulate real user interactions in a browser, to ensure that the UX packages work as expected in a real-world scenario.
Symfony UX uses Playwright for browser automation and testing,
and a dedicated Symfony application located in the apps/e2e/ directory,
which contains many examples of Symfony UX package usages.
Test files are located in the assets/test/browser/ directory of each UX package,
for example: src/Vue/assets/test/browser/vue.test.ts.
Setup:
- Ensure you have followed the steps in the Setting up the development environment section
- Read and follow the instructions in the
apps/e2e/README.mdfile
Running tests:
- At the project's root, you can run the following commands:
pnpm run test:browser: runs the browser tests for all UX packages using a headless browser
- Inside the
assets/directory of each UX package, you can run the following commands:pnpm run test:browser: runs browser tests for the package using a headless browserpnpm run test:browser:ui: runs the browser tests in interactive mode, allowing you to see the tests running in a browser window and debug them if needed
Important
Due to their nature, E2E tests may be slower to run than unit tests.
During development, we recommend running pnpm run test:browser or pnpm run test:browser:ui for a specific UX package.
Tip
If tests are failing locally, try running them in headed mode to see what's happening:
$ pnpm run test:browser:uiSymfony UX documentation is written in ReStructuredText (.rst) and is located in the docs/ directory
of each package.
When contributing to the documentation, please make sure to follow the Symfony documentation guidelines.
To verify your changes locally, you can use the oskarstark/doctor-rst Docker image. Run the following
command from the root directory of the project:
docker run --rm -it -e DOCS_DIR='/docs' -v ${PWD}:/docs oskarstark/doctor-rst -vvvTo keep your fork up-to-date with the upstream repository and 2.x branch:
$ git checkout 2.x && \
git fetch upstream && \
git reset --hard upstream/2.x && \
git push origin 2.xTo rebase your branch on top of the 2.x branch:
$ git checkout my-feature-branch && \
git rebase upstream/2.x && \
git push -u origin my-feature-branch