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!
04.
Unique (but not Insane) Filenames
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!
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
}
}
19 Comments
For anyone following along and having troubles with the using the
Urlizerclass. You can instead use a Slugger class provided from thesymfony/stringcomponent. You can either injectSymfony\Component\String\Slugger\SluggerInterfaceinto your controller method, or just instantiate a slugger manually vianew Symfony\Component\String\Slugger\AsciiSlugger(). Then just call theslug()method on your slugger object and pass in the original filename.Hey @jdevine
That's another way, 100% valid, to generate slugs. Thanks for pointing it out
Cheers!
Hello
when trying to install via ”composer require gedmo/doctrine-extensions” I get messages : Your requirements could not be resolved to an installable set of packages.
I'm using the code from this tutorial as is.
I don't know how to solve this.
”Problem 1
- Root composer.json requires gedmo/doctrine-extensions ^3.0 -> satisfiable by gedmo/doctrine-extensions[v3.0.0].
- gedmo/doctrine-extensions v3.0.0 requires doctrine/common ^2.13 || ^3.0 -> found doctrine/common[2.13.0, 2.13.1, 2.13.2, 2.13.3, 3.0.0, ..., 3.1.0] but the package is fixed to 2.12.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
Problem 2
- stof/doctrine-extensions-bundle is locked to version v1.3.0 and an update of this package was not requested.
- stof/doctrine-extensions-bundle v1.3.0 requires gedmo/doctrine-extensions ^2.3.4 -> found gedmo/doctrine-extensions[v2.3.4, ..., v2.4.42] but it conflicts with your root composer.json require (^3.0).
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.”
sorry, I forgot to type "use Gedmo\Sluggable\Util\Urlizer;"
It's resolved.
Glad you figured it out - thanks for the update!
Hi!
I have a problem, I would really love to use Urlizer, but it seems outdated now. When I do " composer require gedmo/doctrine-extensions", it gives me a lot of errors like:
" - gedmo/doctrine-extensions v2.4.0 requires doctrine/common ~2.4 -> satisfiable by doctrine/common[2.12.0, 2.13.0, 2.13.1, 2.13.2, 2.13.3, v2.10.0, v2.11.0, v2.4.0, v2.4.1, v2.4.2, v2.4.3, v2.5.0, v2.5.1, v2.5.2, v2.5.3, v2.6.0, v2.6.1, v2.6.2, v2.7.0, v2.7.1, v2.7.2, v2.7.3, v2.8.0, v2.8.1, v2.9.0].
- Can only install one of: doctrine/common[2.12.0, 3.0.2].
- ...
- Can only install one of: doctrine/common[v2.9.0, 3.0.2].
- Installation request for doctrine/common (locked at 3.0.2) -> satisfiable by doctrine/common[3.0.2].
Do you know any simple solution to this problem?
Hey @aeiouy
Is it related to course code? If no and you are using latest symfony I'd recommend to use slugger from
symfony/stringcomponent. You can read more about it here https://symfony.com/doc/current/components/string.html#sluggerCheers!
Yes, it's related, cause Urlizer is beeing used in this video so I didn't get the first part of your answer, but slugger fixed my problem so I'm glad you answered me!
Cheers!
I mean you got this output on course code? Which is used for this tutorial? Or it's your personal project which you building using this tutorial?
Hope this is now more clear :)
Cheers!
Ah okay, then you are right.
It was on my personal project :)
Hello,
class Urlizer not defined for me!
done!
composer require gedmo/doctrine-extensions
Hey Abdessamad,
Yep, you need to install the package with Composer first. Glad you figured it out yourself! And thanks for sharing your solution with others.
Cheers!
Could you extend this tutorial and add bits form Webpack Encore with advanced JavaScript (React or Vue) to upload nicely multiple files.
Hey Krzysztof K.!
We are going to cover this... partly :). We're going to cover using Dropzone to upload multiple files via AJAX really nicely (including deleting, updating some info about the files, and even re-ordering). But, because I don't want to make React or Vue a requirement for understanding this, I've tried to keep it simple with jQuery (it's also done outside of Encore, but re-using the code in Encore wouldn't require much change - and we're happy to help).
I hope that satisfies at least a big :).
Cheers!
Thanks Ryan for your answer, but could you cover one particular topic for multiple file upload with preview and image rotation. What I am trying to archive is to see the preview of all selected for upload images, and then have ability to rotate them if needed, before these are send to server. It means that I am not sending original selected files, but modified ones.
So user will select image files, these images will be displayed as a list with a preview, and every image will get set of buttons to rotate or remove form list. I believe that this is a pretty standard requirement which requires few extra features from HTML5/JavaScript (FileReader, Blob, FormData, etc..). If this is achievable with jQuery, please show how :).
I did a lot a lot of googling for that, it is hard to find correct answers and understand what exactly is required.
I work on my own solution but this will work with Base64 (data:image/jpeg;charset=utf-8;base64), some people are using canvas instead, I am not sure why.
ah, one more feature will be required, progress bar for uploaded images.
Hey Krzysztof K.!
Ah... very interesting! I can't guarantee that this will be there - at the moment, I've finished coding the tutorial, but I might add this at the end - i'm not sure. Indeed, being able to do all of this on the client-side before uploading is an interesting challenge.
For the progress bar, we're not talking about that directly, but relying on Dropzone to do that. However, in general, this can be accomplished via JavaScript - there is a way to get notified of upload progress, which you can then use to figure out the percentage (by comparing it with the file's filesize - also available in JS). So, it's not a topic we covered directly - because the heavy-lifting of handling the AJAX upload was handled by Dropzone.
Cheers!
what about multi-file upload ? upload size limit ... etc
Hey Remus M. ,
See this comment: https://symfonycasts.com/sc... - we're going to cover multi-file uploads. And sure, upload size limit and extensions will be covered as well.
Cheers!
"Houston: no signs of life"
Start the conversation!