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!
39.
API-Style Uploads
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
}
}
14 Comments
Hi there !
I am about to implement file upload in my API Platform software. What do you advise me :
1. Implementing the file upload as described in this course
2. Or going with VichUploaderBundle as mentioned in Api Platform documentation ?
Thanks !
Hey Stileex,
Hm, it's mostly a matter of taste, though here are some tips: First of all, if you're looking for a ready-to-use solution - you can leverage the VichUploaderBundle I think. It already has some low-level code written for you, as any other bundle, so it gives you some tools. And so, this sounds like more simple and faster solution.
Or you can go with this course and do all the uploads yourself, but it would mean that you will probably need to write more code as you will have to write that low-level code yourself. However, from the other side, as a benefit, this solution might be also more flexible, and sometimes is better if you need to do some really custom things for your project. And as another benefit, you will know how file uploads works in Symfony behind the scene :)
So, it's up to you! Choose whatever path you like more.
I hope this helps you to make a good choice.
Cheers!
Thanks !
When I run the POST to add a reference, I get the error "Invalid API Token" even though I removed the IsGranted from the annotations. What did I miss?
Hey Skylar
Are you sure you removed all the security? Maybe you are using an Access control list? Check you
security.yamlfileCheers!
I am using the files in the downloaded code Zip file. I have not changed security.yaml. I just followed along with the tutorial.
"Are you sure you removed all the security?" -- what do you mean? I removed the @IsGranted annotation. Is there something additional I need to do? what is triggering the ApiAuthentication?
Hey Skylar!
Hmm. Yea, you're totally right - it's definitely coming from the
ApiTokenAuthenticatorinsidesrc/Security. Double-check that you don't have any "Authentication" headers set inside Postman - you might still have something set from some earlier work you were doing. The ApiTokenAuthenticator should only do its work and cause that error when You are sending anAuthorization: Bearer XXXXXXheader on the request.Let us know what you find!
Cheers!
That was it!! I changed auth to "No Auth" and I was able to continue to follow along. Thank you so much for this Awesome tutorial. It's more than just code...it's how to enjoy the process!!
Woohoo! Alright, now you're unlocked! :D :D
which course will be after this one? are react redux in the planning?
Hey Mouad E.
At the moment we are releasing the "Symfony uploads" tutorial, it's pretty cool, you may enjoy watching it. After that, we are going to release a course about Symfony + API Platform. React Redux is on our scope but just not yet.
Cheers!
Or maybe Symfony translations before API Platform - not entirely sure - a few are being planned currently!
API Platform first please! :)
That's coming soon! I need to fill in after this tutorial with a quick tutorial about Webpack Encore to get it updated, but then I'm right back to making sure we get that API Platform tutorial out as quickly as possible.
"Houston: no signs of life"
Start the conversation!