9

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 Answers 2

11

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')

Sign up to request clarification or add additional context in comments.

4 Comments

HTMLbuilder is no longer in Laravel 4. See: stackoverflow.com/questions/14192750/…
It has been added back a couple of days ago. See the latest answer in the question you just referenced: stackoverflow.com/a/15836987/444215
Ah you're right, I missed that... Just had to update my vendor/laravel/framework directory. Thanks!
Its case-sensitive HTML should be in all caps.
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.