Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

robertmylne's avatar

Storage v Public Folder

I am finding it hard to see the difference between these two folders. Am I right in believing that the public folder would be for things such as user uploaded profile images and storage would be things like user invoices?

Any other examples to help me understand would be appreciated :)

0 likes
8 replies
Fruty's avatar

public is a "WEBROOT" directory. it consists of files which can be accessed from a browser. There is your index.php file, which take a role of your enter point. Also your css, javascript files there.

storage is a folder for cache, logs etc.

3 likes
polarcubs's avatar

If you want some control over who can access what files, put the file into storage.

If everyone can access the file (including non logged in users), put into public

3 likes
mudasir's avatar

@robertmylne if you use storage directory to save invoice then you are giving one directory back access to public user which is not save.

catalinux's avatar

storage it would also be for ulpoading your user content. But still it would be better to keep it protected. You could write a route for accesing those files. This way you might built some authentication meaning for some files

robertmylne's avatar

So if I wanted to store all user invoices that could be downloaded by only the owning user but not accessable from a url I would store them in the storage folder?

pmall's avatar

Yes. Create a protected route that outputs the invoice

IsaacBen's avatar

What if its images that the user uploaded? Does it matter? And how can it be accessed without me adding a route?

Please or to participate in this conversation.