Chapters
21 Chapters
|
2:23:48
|
Login to bookmark this video
-
Course Code
Login or register to download the code!
Login or register to download the code!
-
This Video
Login or register to download the video!
Login or register to download the video!
-
Subtitles
Login or register to download the subtitles!
Login or register to download the subtitles!
-
Course Script
Login or register to download the script!
Login or register to download the script!
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": ">=8.1",
"ext-ctype": "*",
"ext-iconv": "*",
"symfony/asset": "6.0.*", // v6.0.3
"symfony/console": "6.0.*", // v6.0.3
"symfony/dotenv": "6.0.*", // v6.0.3
"symfony/flex": "^2", // v2.4.5
"symfony/framework-bundle": "6.0.*", // v6.0.4
"symfony/monolog-bundle": "^3.0", // v3.7.1
"symfony/runtime": "6.4.3", // v6.4.3
"symfony/twig-bundle": "6.0.*", // v6.0.3
"symfony/ux-turbo": "^2.0", // v2.0.1
"symfony/webpack-encore-bundle": "^1.13", // v1.13.2
"symfony/yaml": "6.0.*", // v6.0.3
"twig/extra-bundle": "^2.12|^3.0", // v3.3.8
"twig/twig": "^2.12|^3.0" // v3.3.8
},
"require-dev": {
"symfony/debug-bundle": "6.0.*", // v6.0.3
"symfony/stopwatch": "6.0.*", // v6.0.3
"symfony/web-profiler-bundle": "6.0.*" // v6.0.3
}
}
6 Comments
There is a nice Chrome extension to view JSON more effectively: JSON Viewer.
Thank you for sharing it!
Hi can i limit my Id wildcard from 1-6? For example if a user edit the url and types 5 the page works but if he types in 7 he gets an error msg?
Hey Usurper,
You can do it either in the method, i.e. just do any check you need and throw
NotFoundHttpException. Or you can write any RegEx you want in thatRoute()config, e.g.#[Route('/api/songs/{id<[12345]>}', methods: ['GET'])]where in square brackets you iterate what chars are allowed.Cheers!
Is it possible to show a standard custom error page for these types of errors? Like when someone requests
api/songs/a, that I can use the Smart route like shown in the video while explaining what is wrong with the request with a special page instead of showing a simple 404? If not directly, then can I somehow pass arguments to my 404 page for prod?Hey @Brentspine ,
Yes, you can customize error pages in Symfony by overriding default templates :) Take a look at this docs page: https://symfony.com/doc/current/controller/error_pages.html
Well, you can't pass vars to that template directly, but you can create a custom Twig function for example that will return you some data you need and call it inside that template :)
Cheers!
"Houston: no signs of life"
Start the conversation!