Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.3 Is safe remove/delete storage folder from Laravel project?

I have a Laravel 5.3 project versioned, and files in this folder are constantly changing.

Is safe to remove from version control system?

If I delete that folder from my working copy, Laravel can keep working?

folder structure

like image 766
Maximiliano Sosa Avatar asked Sep 28 '16 13:09

Maximiliano Sosa


People also ask

Can I delete storage folder in Laravel?

The public_path() is a method Laravel uses to fetch the folder passed as a parameter to the path of the directory. The Storage facade grants access to the file system of the application so that the deleteDirectory() method can delete the specified directory.

How do I delete files from storage folder in Laravel?

One way to delete a file from the public directory in Laravel is to use the Storage facade. To delete a file, you will need to follow the following steps: Step 1: Check to ensure that the folder and file exist. Step 2: Delete the required file.

What is use of storage folder in Laravel?

The storage directory contains your logs, compiled Blade templates, file based sessions, file caches, and other files generated by the framework. This directory is segregated into app , framework , and logs directories. The app directory may be used to store any files generated by your application.


1 Answers

You'll notice in a default Laravel 5.3 install there are 3 folders within storage. It looks like this:

+ storage
    + app
    + framework
    + logs

And each of those subfolders has a .gitignore as well as other folders (also usually with gitignores. Those .gitignore files generally say to ignore all files except for the .gitignore. For example, this is the .gitignore inside storage/logs:

*
!.gitignore

That means that you can keep this in version control, but any file written to that folder (except for the .gitignore file itself) will NOT be in your git repository.

Also, it might help to know that these folders have a specific purpose:

app: Designed to be used as storage for files outside of your root public folder

framework: By defaut, this is where Laravel writes a lot of its files for cache and views

logs: Where the error logs are written

If you delete the root storage folder or these subfolders, the framework will have trouble finding these files and you'll get errors.

like image 130
tptcat Avatar answered Oct 19 '22 12:10

tptcat