It seems like you get different relative paths depending on how you are executing the script: console or web.
I find this extremely annoying, haven’t you had any issues with this?
Every time I need to copy/move/delete files, I have to be thinking if I’m on cli or web, if I saved it as cli or web path, etc.
Eg: Say someone uploads an image. You will probably store the image with this kind of path: uploads/picture-123.jpeg. Then a cronjob decides to move the picture or something. First it will have to preppend this to the source path: web/. It will also need a target path, that begins with web/. After moving it, it will want to save the new path in the corresponding database row or document, so it will have to strip web/ from the target path.
Any thoughts?
For handling files the best practice for paths defining is to use absolute ones, that start from
%kernel.root_dir%: