-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor the Uploading Document #2346
Comments
@weaverryan I totally agree that we need an article for the upload without doctrine 👍 |
Could someone please label this issue with the DX label? Thanks! |
Done! This is a huge issue. |
what about handling file upload in i really don't understand why everyone (s2 cookbook, VichUploaderBundle, all the blog posts/tutorials) is putting the logic into entity class. in my understanding, it doesn't belong there at all. it belongs to form processing, not to data storing. edit 1:
what symfony is forcing me to do:
why this has to be this complicated? |
Hey @gondo! First, the cookbook is just wrong, and I think a lot of blogs have probably followed that :). About VichUploaderBundle, it only has the configuration in the entity (other than the extra property, you have a point with this), which is no different than having the Doctrine or Validation metadata there. So, you're not missing anything - you are correct imo! You bring up some great points about how complex this can be, but that's more of an issue for the core than the docs. Cheers! |
This PR was merged into the 2.3 branch. Discussion ---------- Added a new cookbook about file uploading | Q | A | ------------- | --- | Doc fix? | no | New docs? | yes | Applies to | all | Fixed tickets | #2346 This PR is completely based on the work made by @saro0h in #4018. All the credit for the original work goes to her. I just picked her work and applied the suggestions made by @weaverryan @xabbuh and @wouterj to make it mergeable. If you agree with this PR, please merge it as soon as possible because this is a very important topic and we're a bit late on this doc. Thanks! Commits ------- 4a7709b Fixed all the issues spotted by Ryan 20ae21b Added a new cookbook about file uploading
I think we can close this issue now that #5375 is merged. |
@javiereguiluz what do you think about removing http://symfony.com/doc/current/cookbook/doctrine/file_uploads.html entirely now? |
I agree ... but only when I implement the changes that you suggested here #5375 (comment) I plan to do that soon. |
@javiereguiluz if that's on your list (which would be awesome), then I'll close this :). Thanks! |
The document in question: http://symfony.com/doc/current/cookbook/doctrine/file_uploads.html
There are a number of open issues about this document:
Here's a summary of issues:
a) I really dislike the use of paths inside the entity itself
b) Complication of the callbacks not triggering if only the file object property is changed (since it's not mapped). This may not be avoidable, but should be solved as simply as possible).
c) I agree that the VichUploaderBundle should be suggested to help with much of this
Suggestions: One big theme is building-up in complexity from little to more.
We should first show how to upload files. It's very easy and includes implementing the UploadedFile object which you can get off of the Request. This should live as a little "cookbook" in the HttpFoundation component
Have a cookbook article that talks about uploading in Symfony, but nothing about Doctrine. This would include using a Form, validation, and moving the uploaded file in the controller.
Update the Doctrine file uploads doc to build off of the new, short doc in (2). So, it would start with pointing you to (2), then continue by building an entity, persisting, etc.
Questions
/uploads/avatars
and the second in/uploads/products
. Where each type is stored should be stored in configuration somewhere, then accessed in the controller and in the view. I want to show a nice, but still simple way you might handle this.The text was updated successfully, but these errors were encountered: