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:
76
8- However, Symfony *does * come with two powerful options to help you build a modern,
7+ #. :ref: `building your HTML with PHP & Twig <frontend-twig-php >`;
8+ #. :ref: `building your frontend with a JavaScript framework <frontend-js >` like React.
9+
10+ Both work great - and are discussed below.
11+
12+ .. _frontend-twig-php :
13+
14+ Using PHP & Twig
15+ ----------------
16+
17+ Symfony comes with two powerful options to help you build a modern,
918fast frontend, *and * enjoy the process:
1019
1120* :ref: `AssetMapper <frontend-asset-mapper >` (recommended for new projects) runs
@@ -39,7 +48,7 @@ be executed by a browser.
3948.. _frontend-asset-mapper :
4049
4150AssetMapper (Recommended)
42- -------------------------
51+ ~~~~~~~~~~~~~~~~~~~~~~~~~
4352
4453AssetMapper is the recommended system for handling your assets. It runs entirely
4554in PHP with *no * complex build step or dependencies. It does this by leveraging
@@ -51,7 +60,7 @@ to a polyfill.
5160.. _frontend-webpack-encore :
5261
5362Webpack Encore
54- --------------
63+ ~~~~~~~~~~~~~~
5564
5665.. screencast ::
5766
@@ -65,7 +74,7 @@ asset system that's a *delight* to use.
6574:doc: `Read the Encore Documentation </frontend/encore/index >`
6675
6776Stimulus & Symfony UX Components
68- --------------------------------
77+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6978
7079Once you've installed AssetMapper or Encore, it's time to start building your
7180front-end. You can write your JavaScript however you want, but we recommend
@@ -74,6 +83,18 @@ using `Stimulus`_, `Turbo`_ and a set of tools called `Symfony UX`_.
7483To learn about Stimulus & the UX Components, see:
7584the `StimulusBundle Documentation `_
7685
86+ .. _frontend-js :
87+
88+ Using a Front-end Framework (React, Vue, Svelte, etc)
89+ -----------------------------------------------------
90+
91+ If you want to use a front-end framework (Next.js, React, Vue, Svelte, etc),
92+ we recommend using their native tools and using Symfony as a pure API. A wonderful
93+ tool to do that is `API Platform `_. Their standard distribution comes with a
94+ Symfony-powered API backend, frontend scaffolding in Next.js (other frameworks
95+ are also supported) and a React admin interface. It comes fully Dockerized and even
96+ contains a web server.
97+
7798Other Front-End Articles
7899------------------------
79100
@@ -89,3 +110,4 @@ Other Front-End Articles
89110.. _Stimulus : https://stimulus.hotwired.dev/
90111.. _Turbo : https://turbo.hotwired.dev/
91112.. _Symfony UX : https://ux.symfony.com
113+ .. _API Platform : https://api-platform.com/
0 commit comments