Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 issues with linking css assets

am currently trying to port my laravel 4 application to laravel 5 . i have added "illuminate/html": "5.*" to composer and also the facade and service providers to config. i was using the following syntax to link to my css files

{{ HTML::style('css/bootstrap.min.css') }}
{{ HTML::style('css/style.css') }}

but in laravel 5 , my views output is all broken , with the page displaying like the below screenshot .

laravel blade issue.

what could i be missing here ? is there any changes to the blade syntax in laravel 5 ?

like image 649
Sojan Jose Avatar asked Jan 01 '15 01:01

Sojan Jose


People also ask

Why css is not working in laravel?

Try using Mix to copy the assets from the /vendor dirs to your /public dirs (ie /public/css and /public/js). Then use those paths for your assets in the html. Don't think you should be loading assets from the vendor dir.

Where do I put css files in laravel?

blade. php file in side the pages folder and css file is in the public/css folder.

Where should I store css and js in laravel?

I usually place them inside of the public folder i create a assets directory that contains the js and css files but you can also place them inside of resources/assets directory as well. I believe laravel comes built in with those directories.


2 Answers

found the answer here on this thread and here . on the second thread Taylor Otwell gives the answer himself . In laravel 5 , the laravel 4 default syntax {{ code }} , will escape the data output . if you want unescaped html data, you have to use the new syntax

{!! HTML::style('css/style.css') !!}

if you want to revert to previous syntax you can use

Blade::setRawTags('{{', '}}');
like image 63
Sojan Jose Avatar answered Sep 19 '22 20:09

Sojan Jose


  1. Check if the assets are there, and are being linked properly.
  2. check permission and set chmod to 777 (Unix).
  3. If that doesn't work, use <link rel="stylesheet" type="text/css" href="{{asset('relative/to/public/folder.css')}}" > manually.
like image 23
Yousof K. Avatar answered Sep 18 '22 20:09

Yousof K.