Chapters
28 Chapters
|
2:51:42
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!
Subscribe to download the code!
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Subtitles
Subscribe to download the subtitles!
Subscribe to download the subtitles!
-
Course Script
Subscribe to download the script!
Subscribe 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.2",
"ext-ctype": "*",
"ext-iconv": "*",
"api-platform/core": "^3.0", // v3.0.8
"doctrine/annotations": "^1.0", // 1.14.2
"doctrine/doctrine-bundle": "^2.8", // 2.8.0
"doctrine/doctrine-migrations-bundle": "^3.2", // 3.2.2
"doctrine/orm": "^2.14", // 2.14.0
"nelmio/cors-bundle": "^2.2", // 2.2.0
"nesbot/carbon": "^2.64", // 2.64.1
"phpdocumentor/reflection-docblock": "^5.3", // 5.3.0
"phpstan/phpdoc-parser": "^1.15", // 1.15.3
"symfony/asset": "6.2.*", // v6.2.0
"symfony/console": "6.2.*", // v6.2.3
"symfony/dotenv": "6.2.*", // v6.2.0
"symfony/expression-language": "6.2.*", // v6.2.2
"symfony/flex": "^2", // v2.2.4
"symfony/framework-bundle": "6.2.*", // v6.2.3
"symfony/property-access": "6.2.*", // v6.2.3
"symfony/property-info": "6.2.*", // v6.2.3
"symfony/runtime": "6.2.*", // v6.2.0
"symfony/security-bundle": "6.2.*", // v6.2.3
"symfony/serializer": "6.2.*", // v6.2.3
"symfony/twig-bundle": "6.2.*", // v6.2.3
"symfony/ux-react": "^2.6", // v2.6.1
"symfony/validator": "6.2.*", // v6.2.3
"symfony/webpack-encore-bundle": "^1.16", // v1.16.0
"symfony/yaml": "6.2.*" // v6.2.2
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.4", // 3.4.2
"symfony/debug-bundle": "6.2.*", // v6.2.1
"symfony/maker-bundle": "^1.48", // v1.48.0
"symfony/monolog-bundle": "^3.0", // v3.8.0
"symfony/stopwatch": "6.2.*", // v6.2.0
"symfony/web-profiler-bundle": "6.2.*", // v6.2.4
"zenstruck/foundry": "^1.26" // v1.26.0
}
}
14 Comments
Hello Symfonycasts colleagues,
When clicking on one of the records from the profile search (404 127.0.0.1 GET
https://127.0.0.1:8000/api/projectss.json 20-Apr-2024
13:41:01
5dae03) I have got the following error message.
How can I resolve this error.
Format "json" is not supported
Hey Benoit,
Any chance you misprinted the URL in your browser? I suppsoe it should be: https://127.0.0.1:8000/api/projects.json - remove double "ss" in "projectss". I wonder if that helps
Cheers!
Hi Ryan,
Is it possible to completely remove the PUT item operation from my API in the
api_platform.yamlfile?Thank you,
Sean
I was able to find this configuration using
bin/console config:dump api_platformTo globally override the PUT operation in
config/packages/api_platform.yamlI was able to include all operations except PUT under the api_platform default operations settings. For example:Hey Sean,
Good catch, I'm glad to hear you were able to find the solution yourself, well done! Yeah, dome debug commands might be really helpful :)
Cheers!
Hi Ryan,
I am unable to execute POST operations: error 500 "The class 'ApiPlatform\Metadata\Post' was not found in the chain configured namespaces App\Entity".
I cannot figure out why others operations class are working well but not this one...
Have an idea ?
Best regards
Chris
Hey @Chris-M!
Hmm. What does the stacktrace look like on that error? Is it coming from Doctrine? I think I recognize that error from Doctrine... and so it almost looks like Doctrine thinks that there is an entity called
ApiPlatform\Metadata\Post. So, I'm not sure, but this looks bizarre enough that my gut is that there is some small typo somewhere causing a big issue. Are you other operations working - e.g.Get,Patch, etc?Cheers!
And for the other operations, I can't have anything done as it looks like the issue is blocking as soon as the class is constructed... So, I got the same response with a Get, Patch or others... :(
Here the complete reponse from the API
{
"@context": "/api/contexts/Error",
"@type": "hydra:Error",
"hydra:title": "An error occurred",
"hydra:description": "The class 'ApiPlatform\Metadata\Post' was not found in the chain configured namespaces App\Entity",
"trace": [
]
}
Hmm yea, somehow it thinks that
Postis an entity that it needs to query for. What does the top of your class (basically everything from theclasskeyword and above to the top of the file) look like? Is the wordPostused anywhere else in your class?That's it ! It was not actually on the top of my class, but missing : my class refers to an Entity Post, and I think I change the use (bad idea !).
I wrote back the use with an alias and refered to this alias in my class and... tadam ! Job is done !
Thank you Ryan ! You rock !
Woohoo! Good find - keep up the good work!
Hi Ryan,
I am unable to execute PUT/PATCH operations on my server (Error 405 Method not allowed). I am using Fastpanel where Nginx is running for the frontend. Tried some fixes from the internet but that didn't help. Any help would be really appreciated.
Best regards,
Stiff
Hey Stiff!
Hmm, well that's no fun :/. First, are you sure that the 405 Method not allowed is coming from Nginx? I mean, it probably is, but it could also, in theory, be coming from something like CloudFlare (if it is, it should be pretty obvious on that page) or Symfony itself (if it is, you would likely be seeing either your custom exception page or the generic "Symfony error page" for production).
Assuming that it IS coming from nginx, I'm familiar with Fastpanel or how much control it gives you over the raw nginx config. What have you tried so far?
Cheers!
"Houston: no signs of life"
Start the conversation!