11Front-end Tools: Handling CSS & JavaScript
22==========================================
33
4- Symfony gives you the flexibility to choose any front-end tools you want. This could
5- be dead-simple - like putting CSS & JS directly in the ``public/ `` directory - or
6- more advanced - like scaffolding your front-end with a tool like Next.js.
4+ Symfony gives you the flexibility to choose any front-end tools you want. There
5+ are generally two approaches: :ref: `building your HTML with PHP & Twig <frontend-twig-php >`
6+ or :ref: `building your frontend with a JavaScript framework <frontend-js >` like React.
7+ Both work great - and are discussed below.
78
8- However, Symfony *does * come with two powerful options to help you build a modern,
9+ .. _frontend-twig-php :
10+
11+ Using PHP & Twig
12+ ----------------
13+
14+ Symfony comes with two powerful options to help you build a modern,
915fast frontend, *and * enjoy the process:
1016
1117* :ref: `AssetMapper <frontend-asset-mapper >` (recommended for new projects) runs
@@ -39,7 +45,7 @@ be executed by a browser.
3945.. _frontend-asset-mapper :
4046
4147AssetMapper (Recommended)
42- -------------------------
48+ ~~~~~~~~~~~~~~~~~~~~~~~~~
4349
4450AssetMapper is the recommended system for handling your assets. It runs entirely
4551in PHP with *no * complex build step or dependencies. It does this by leveraging
@@ -51,7 +57,7 @@ to a polyfill.
5157.. _frontend-webpack-encore :
5258
5359Webpack Encore
54- --------------
60+ ~~~~~~~~~~~~~~
5561
5662.. screencast ::
5763
@@ -65,7 +71,7 @@ asset system that's a *delight* to use.
6571:doc: `Read the Encore Documentation </frontend/encore/index >`
6672
6773Stimulus & Symfony UX Components
68- --------------------------------
74+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6975
7076Once you've installed AssetMapper or Encore, it's time to start building your
7177front-end. You can write your JavaScript however you want, but we recommend
@@ -74,6 +80,18 @@ using `Stimulus`_, `Turbo`_ and a set of tools called `Symfony UX`_.
7480To learn about Stimulus & the UX Components, see:
7581the `StimulusBundle Documentation `_
7682
83+ .. _frontend-js :
84+
85+ Using a Front-end Framework (React, Vue, Svelte, etc)
86+ -----------------------------------------------------
87+
88+ If you want to use a front-end framework (Next.js, React, Vue, Svelte, etc),
89+ we recommend using their native tools and using Symfony as a pure API. A wonderful
90+ tool to do that is `API Platform `_. Their standard distribution comes with a
91+ Symfony-powered API backend, frontend scaffolding in Next.js (other frameworks
92+ are also supported) and a React admin interface. It comes fully Dockerized and even
93+ contains a web server.
94+
7795Other Front-End Articles
7896------------------------
7997
@@ -89,3 +107,4 @@ Other Front-End Articles
89107.. _Stimulus : https://stimulus.hotwired.dev/
90108.. _Turbo : https://turbo.hotwired.dev/
91109.. _Symfony UX : https://ux.symfony.com
110+ .. _API Platform : https://api-platform.com/
0 commit comments