Due to its nature, the Symfony UX Toolkit requires a specific setup to develop and test it properly. Please follow the instructions below to set up your development environment.
First, ensure you have followed the Symfony UX's Contribution Guide to set up your fork of the main repository, install dependencies, etc.
Then, install the UX Toolkit dependencies:
# src/Toolkit
composer installCurrently, kits can only be previewed through the Symfony UX Website. Installation instructions can be found in the Symfony UX Website's README.md.
Then, run the following commands from the ux.symfony.com/ directory:
# Link local UX packages
php ../link
# Run the local web server
symfony serve -dWhen the server is running, you can access:
- The UX Toolkit homepage at https://127.0.0.1:9044/toolkit
- The list of available kits at https://127.0.0.1:9044/toolkit#kits
- A dedicated section for each kit, e.g., https://127.0.0.1:9044/toolkit/kits/shadcn for the Shadcn UI Kit
A kit is composed of several recipes, each providing Twig components, styles, and JavaScript.
- Each kit is located in the
src/Toolkit/kits/directory - Each kit has its own directory named after the kit, e.g.,
shadcn/for the Shadcn UI Kit - Each kit directory contains:
- An
INSTALL.mdfile with installation instructions (used by the UX Website) - A
manifest.jsonfile containing metadata about the kit: its name, description, license, homepage, etc. - A folder for each recipe provided by the kit, e.g.,
button/for the Button recipe
- An
- Each recipe directory contains:
- A
manifest.jsonfile containing metadata about the recipe: its type, name, description, files to copy, dependencies, etc. - A folder
examples/containing Twig files, it is used for Toolkit tests and previews on UX website - Based on the "files to copy" setting, the kit may contain subdirectories such as:
templates/components/for Twig componentsassets/controllers/for Stimulus controllers
- The "files to copy" structure is flexible, but we recommend following the above conventions for consistency across kits and Symfony apps
- A
After setting up your development environment and the UX Website locally, you can start modifying the kits and testing them.
Adding new recipes or modifying existing ones will be automatically reflected in the UX Website, thanks to the local linking done with the php link command.
You can then preview your changes by navigating to the relevant sections in the UX Website.
Tests use snapshots to ensure that the kits and their recipes work as expected and to prevent regressions.
Snapshots are created from all Twig code examples provided in each recipe's examples/ folder.
The Twig code examples are rendered in an isolated environment.
The rendered output is then compared to stored snapshots to ensure that the kit's recipes work as expected.
To update the snapshots, run the following command from the src/Toolkit/ directory:
# Remove existing snapshots (may be useful if some Twig code examples were removed)
rm -fr tests/Functional/__snapshots__
# Run tests and update snapshots
php vendor/bin/simple-phpunit -d --update-snapshots
# Add the updated snapshots to git
git add tests/Functional/__snapshots__