Sunday, January 30, 2022

[FIXED] Load css/js files in Laravel 4 with Composer?

Issue

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.


Solution

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



Answered By - Barryvdh

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.