1
1
Front-end Tools: Handling CSS & JavaScript
2
2
==========================================
3
3
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:
7
6
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,
9
18
fast frontend, *and * enjoy the process:
10
19
11
20
* :ref: `AssetMapper <frontend-asset-mapper >` (recommended for new projects) runs
@@ -39,7 +48,7 @@ be executed by a browser.
39
48
.. _frontend-asset-mapper :
40
49
41
50
AssetMapper (Recommended)
42
- -------------------------
51
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
43
52
44
53
AssetMapper is the recommended system for handling your assets. It runs entirely
45
54
in PHP with *no * complex build step or dependencies. It does this by leveraging
@@ -51,7 +60,7 @@ to a polyfill.
51
60
.. _frontend-webpack-encore :
52
61
53
62
Webpack Encore
54
- --------------
63
+ ~~~~~~~~~~~~~~
55
64
56
65
.. screencast ::
57
66
@@ -65,7 +74,7 @@ asset system that's a *delight* to use.
65
74
:doc: `Read the Encore Documentation </frontend/encore/index >`
66
75
67
76
Stimulus & Symfony UX Components
68
- --------------------------------
77
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
69
78
70
79
Once you've installed AssetMapper or Encore, it's time to start building your
71
80
front-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`_.
74
83
To learn about Stimulus & the UX Components, see:
75
84
the `StimulusBundle Documentation `_
76
85
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
+
77
98
Other Front-End Articles
78
99
------------------------
79
100
@@ -89,3 +110,4 @@ Other Front-End Articles
89
110
.. _Stimulus : https://stimulus.hotwired.dev/
90
111
.. _Turbo : https://turbo.hotwired.dev/
91
112
.. _Symfony UX : https://ux.symfony.com
113
+ .. _API Platform : https://api-platform.com/
0 commit comments