9
votes

I'm working on creating a new project in Laravel 4. I have a tiny bit of experience in Laravel 3, in which I got used to the assets system. I'm now having a lot of trouble figuring out how to load CSS and JS files in the new system.

I believe I should be using Composer PHP, but I'm not sure how. Where do I put the actual .css and .js files? And then how do I load them with Composer to be utilized in the Laravel project?

I know there are outside plugins like Best Asset, etc. that are written to replicate the Assets system of Laravel 3, but I was hoping to understand the new system and not have to use an outside plugin.

Any help? Thanks.

2

2 Answers

11
votes

You don't need Composer for your css/js assets. You can use assets pretty much the same as with Laravel 3

You can just place them in your public folder and reference them in your views. You can use plain html, or use the HtmlBuilder: HTML::style('style.css') and HTML::script('script.js')

1
votes

You must take care of case sensitive.
This class must write with uppercase.

HTML::style('style.css');
HTML::script('script.js');

Laravel stylesheets and javascript don't load for non-base routes