Laravel 5.0 folder structure: public vs. resources

前端 未结 4 1856
灰色年华
灰色年华 2020-12-13 08:58

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 a

相关标签:
4条回答
  • 2020-12-13 09:19

    In laravel public folder is best for Image, CSS, and Javascripts. In public folder we can use for uploaded images, videos, text files etc.

    0 讨论(0)
  • 2020-12-13 09:20

    You can think of them as being separate folders for development and production. In resources you have all your development files that'll not ship off into production (SASS, Coffeescript, Babel, Jade, etc). But when they're compiled (or piped through something like Gulp) you can configure them to output to public, the production folder.

    0 讨论(0)
  • 2020-12-13 09:32

    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.

    0 讨论(0)
  • 2020-12-13 09:33

    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.

    When working this way, you can have all your files concatenated and minified with gulp and less effort. Simply include them from your public folder.

    0 讨论(0)
提交回复
热议问题