Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d61c9ee

Browse filesBrowse files
committed
Merge branch '5.3' into 5.4
* 5.3: Remove unused param from LeapYearController::index Fix some line numbers in a code example Add Attributes code Update mercure.rst
2 parents d032f3b + 90936ab commit d61c9ee
Copy full SHA for d61c9ee

File tree

Expand file treeCollapse file tree

4 files changed

+44
-23
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+44
-23
lines changed

‎create_framework/http_kernel_httpkernel_class.rst

Copy file name to clipboardExpand all lines: create_framework/http_kernel_httpkernel_class.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ instead of a full Response object::
133133

134134
class LeapYearController
135135
{
136-
public function index(Request $request, $year)
136+
public function index($year)
137137
{
138138
$leapYear = new LeapYear();
139139
if ($leapYear->isLeapYear($year)) {

‎mercure.rst

Copy file name to clipboardExpand all lines: mercure.rst
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ Subscribing to updates in JavaScript from a Twig template is straightforward:
251251
// Will be called every time an update is published by the server
252252
console.log(JSON.parse(event.data));
253253
}
254-
<script>
254+
</script>
255255
256256
The ``mercure()`` Twig function will generate the URL of the Mercure hub
257257
according to the configuration. The URL will include the ``topic`` query
@@ -260,13 +260,15 @@ parameters corresponding to the topics passed as first argument.
260260
If you want to access to this URL from an external JavaScript file, generate the
261261
URL in a dedicated HTML element:
262262

263-
.. code:: twig
263+
.. code-block:: twig
264264
265-
<script type="application/json" id="mercure-url">{{ mercure('https://example.com/books/1')|json_encode(constant('JSON_UNESCAPED_SLASHES') b-or constant('JSON_HEX_TAG'))|raw }}</script>
265+
<script type="application/json" id="mercure-url">
266+
{{ mercure('https://example.com/books/1')|json_encode(constant('JSON_UNESCAPED_SLASHES') b-or constant('JSON_HEX_TAG'))|raw }}
267+
</script>
266268
267269
Then retrieve it from your JS file:
268270

269-
.. code:: javascript
271+
.. code-block:: javascript
270272
271273
const url = JSON.parse(document.getElementById("mercure-url").textContent);
272274
const eventSource = new EventSource(url);

‎migration.rst

Copy file name to clipboardExpand all lines: migration.rst
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,15 +289,15 @@ could look something like this::
289289

290290
There are 2 major deviations from the original file:
291291

292-
Line 15
292+
Line 18
293293
First of all, ``$kernel`` is made globally available. This allows you to use
294294
Symfony features inside your existing application and gives access to
295295
services configured in our Symfony application. This helps you prepare your
296296
own code to work better within the Symfony application before you transition
297297
it over. For instance, by replacing outdated or redundant libraries with
298298
Symfony components.
299299

300-
Line 38 - 47
300+
Line 41 - 50
301301
Instead of sending the Symfony response directly, a ``LegacyBridge`` is
302302
called to decide whether the legacy application should be booted and used to
303303
create the response instead.

‎page_creation.rst

Copy file name to clipboardExpand all lines: page_creation.rst
+35-16Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,34 +95,53 @@ Annotation Routes
9595
-----------------
9696

9797
Instead of defining your route in YAML, Symfony also allows you to use *annotation*
98-
routes. To do this, install the annotations package:
98+
or *attribute* routes. Attributes are built-in in PHP starting from PHP 8. In earlier
99+
PHP versions you can use annotations. To do this, install the annotations package:
99100

100101
.. code-block:: terminal
101102
102103
$ composer require annotations
103104
104105
You can now add your route directly *above* the controller:
105106

106-
.. code-block:: diff
107+
.. configuration-block::
107108

108-
// src/Controller/LuckyController.php
109+
.. code-block:: php-annotations
109110
110-
// ...
111-
+ use Symfony\Component\Routing\Annotation\Route;
111+
// src/Controller/LuckyController.php
112112
113-
class LuckyController
114-
{
115-
+ /**
116-
+ * @Route("/lucky/number")
117-
+ */
118-
public function number()
119-
{
120-
// this looks exactly the same
121-
}
122-
}
113+
// ...
114+
+ use Symfony\Component\Routing\Annotation\Route;
115+
116+
class LuckyController
117+
{
118+
+ /**
119+
+ * @Route("/lucky/number")
120+
+ */
121+
public function number()
122+
{
123+
// this looks exactly the same
124+
}
125+
}
126+
127+
.. code-block:: php-attributes
128+
129+
// src/Controller/LuckyController.php
130+
131+
// ...
132+
+ use Symfony\Component\Routing\Annotation\Route;
133+
134+
class LuckyController
135+
{
136+
+ #[Route('/lucky/number')
137+
public function number()
138+
{
139+
// this looks exactly the same
140+
}
141+
}
123142
124143
That's it! The page - http://localhost:8000/lucky/number will work exactly
125-
like before! Annotations are the recommended way to configure routes.
144+
like before! Annotations/attributes are the recommended way to configure routes.
126145

127146
.. _flex-quick-intro:
128147

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.