In Laravel 4.2, I used public folder to store all my CSS, JS, images and uploads. Currently, there's a new resources folder with assets folder in it coming with Laravel 5.0 installation:
/public
/resources/assets
This is confusing to me, especially because resources also holds views in it.
Via Laravel's upgrade guide (4.2 to 5.0):
Copy your application's public assets from your 4.2 application's public directory to your new application's public directory.
and further:
You may move your Sass, Less, or CoffeeScript to any location you wish. The resources/assets directory could be a good default location.
Question: What is the actual difference between public and resources folders in Laravel 5.0 folder structure?
Laravel elixir, by default uses the /resources/assets folder as the base directory for scripts to be compiled, minified and so on. So you should put your raw sass, less, coffeescript, js and css files in there to let elixir do it's work. A good place for the files you are using is the public folder.
The files and folders in laravels public folder are meant to be web accessible. For security, all other files and folders in the laravel framework should not be web accessible.
This lookup could be any folder on the server. Take for instance the following folder: /var/www/html/devdojo/ . The folder lookup location can be set up through the server or the hosting provider. If I had setup a Laravel app in my /var/www/html/devdojo/ folder and this is folder my server looks to serve up an index.
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.
The big difference here is that everything in public
is... well public. resources
aren't. What you put in where is up to you.
Generally you would have everything the browser needs to access directly in the public directory. Which usually means: JavaScript, CSS, images, maybe some videos or audio files.
resources/assets
is meant for things that have to be compiled or minified first. So you would have a few LESS or SASS files in resources/assets
and they would get compiled and minified into one CSS file that's put in the public
directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With