Chapters
40 Chapters
|
4:39:58
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: ^7.1.3
Subscribe to download the code!Compatible PHP versions: ^7.1.3
-
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!
26.
API Endpoint & Errors with Dropzone
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!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
This tutorial is built on Symfony 4 but works great in Symfony 5!
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": "^7.1.3",
"ext-iconv": "*",
"aws/aws-sdk-php": "^3.87", // 3.87.10
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"doctrine/annotations": "^1.0", // 1.10.1
"doctrine/doctrine-bundle": "^1.6.10", // 1.10.2
"doctrine/doctrine-migrations-bundle": "^1.3|^2.0", // v2.0.0
"doctrine/orm": "^2.5.11", // v2.7.2
"knplabs/knp-markdown-bundle": "^1.7", // 1.7.1
"knplabs/knp-paginator-bundle": "^2.7", // v2.8.0
"knplabs/knp-time-bundle": "^1.8", // 1.9.0
"league/flysystem-aws-s3-v3": "^1.0", // 1.0.22
"league/flysystem-cached-adapter": "^1.0", // 1.0.9
"liip/imagine-bundle": "^2.1", // 2.1.0
"nexylan/slack-bundle": "^2.0,<2.2.0", // v2.1.0
"oneup/flysystem-bundle": "^3.0", // 3.0.3
"php-http/guzzle6-adapter": "^1.1", // v1.1.1
"phpdocumentor/reflection-docblock": "^3.0|^4.0", // 4.3.0
"sensio/framework-extra-bundle": "^5.1", // v5.2.4
"stof/doctrine-extensions-bundle": "^1.3", // v1.3.0
"symfony/asset": "^4.0", // v4.2.3
"symfony/console": "^4.0", // v4.2.3
"symfony/flex": "^1.9", // v1.21.6
"symfony/form": "^4.0", // v4.2.3
"symfony/framework-bundle": "^4.0", // v4.2.3
"symfony/property-access": "4.2.*", // v4.2.3
"symfony/property-info": "4.2.*", // v4.2.3
"symfony/security-bundle": "^4.0", // v4.2.3
"symfony/serializer": "4.2.*", // v4.2.3
"symfony/twig-bundle": "^4.0", // v4.2.3
"symfony/validator": "^4.0", // v4.2.3
"symfony/web-server-bundle": "^4.0", // v4.2.3
"symfony/yaml": "^4.0", // v4.2.3
"twig/extensions": "^1.5" // v1.5.4
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.0", // 3.1.0
"easycorp/easy-log-handler": "^1.0.2", // v1.0.7
"fzaninotto/faker": "^1.7", // v1.8.0
"symfony/debug-bundle": "^3.3|^4.0", // v4.2.3
"symfony/dotenv": "^4.0", // v4.2.3
"symfony/maker-bundle": "^1.0", // v1.11.3
"symfony/monolog-bundle": "^3.0", // v3.3.1
"symfony/phpunit-bridge": "^3.3|^4.0", // v4.2.3
"symfony/stopwatch": "4.2.*", // v4.2.3
"symfony/var-dumper": "^3.3|^4.0", // v4.2.3
"symfony/web-profiler-bundle": "4.2.*" // v4.2.3
}
}
8 Comments
Hello, for information, on Symfony 5.2.6, I got an empty JSON in my response (for the part at 3:06).
It seems that now, in case of a single "group", you need to set the group directly in a string instead of an array.
More concisely:
`
return $this->json(
);
`
Instead of:
`
return $this->json(
);
`
Otherwise, you'll get an empty JSON as Response.
Also huge thanks to the SymfonyCasts crew, your tutorials are amazing!
Hi glioburd!
Thanks for the nice message and the note about the groups! I'm not sure why that change would be required... but we're going to take a look at it and see if we can repeat. If we can, we'll add a note to the tutorial :).
Cheers!
Hi again!
I just wanted to follow-up. I wasn't able to repeat this issue at the step in the tutorial after upgrading to Symfony 5.3... so I'm not sure what's going on :). Passing
['groups' => ['main']]and >['groups' => 'main']` behave identically for me... which is what I would expect - this is the deep, dark function internally that fetches these and makes sure they're an array if you pass a scalar: https://github.com/symfony/symfony/blob/d679ac56503c54724515044551b61279bf23f0ef/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php#L267-L272So, who know what happened - but I think things are all good here. But if you do ever run into this again and can repeat it, let us know1
Cheers!
How could you parse violations into json format as {"type"=>"","title"=>"","detail"=>""}?
I tried . It return like an json array with lots message.
I see. My Enviroment is Symfony 3 .
But maybe it is a new feature in Symfony 4?
https://symfony.com/blog/ne...
Hey Wei lun L.
Yep, as you already know from that blog post, the ability to directly serialize a
ConstraintViolationListobject it's a feature of Symfony 4.1Cheers!
File upload works fine in Chrome but having an issue in IE when I select multiple files they are not uploaded (file is visible in Dropzone with Cross "X") with this Error message:
{"type":"https:\/\/symfony.com\/errors\/validation","title":"Validation Failed","detail":"Please select a file to upload","violations":[{"propertyPath":"","title":"Please select a file to upload","type":"urn:uuid:c1051bb4-d103-4f74-8988-acbcafc7fdc3"}]}my feeling is that Ie doesnt support those arrow functions...
I dont use IE so I dont need a fix but just saying for those who might be
Hey Peter K.
Thanks for sharing it. If the problem is what you believe, then using a polyfill might solve the issue, or maybe, Dropzone library has a bug while working on IE? Anyways, in my opinion we should let IE just die in peace:) hehehe
Cheers!
"Houston: no signs of life"
Start the conversation!