2

I was given a Laravel project and I manage to download it's configuration and get it started on php artisan serve.

When I open it on localhost:8000 It opens but only the html portion of it.

It seems like css files didn't load for it.

Is there some sort of package we need to install with composer in my environment.

To get the css working.

The public folder looks like this in the laravel project.

    backend  favicon.ico  front  images  index.html  index.php  js  robots.txt  sql  vendor  
    web.config
5
  • where are the css files? Commented Jun 17, 2020 at 1:59
  • they are in backend > Css folder. What is the right way to put them. Commented Jun 17, 2020 at 2:36
  • I am asking maybe there some sort of package or dependency that is required to be installed that boosts up the css and js in laravel. Because It's first time I am using it and I might not have installed it on my machine before. Commented Jun 17, 2020 at 2:52
  • nothing special, just point the src to the correct url asset('backend/Css/something.css') Commented Jun 17, 2020 at 3:10
  • laravel.com/docs/7.x/frontend#writing-css This is the link of laravel css/js startup. I tried to run these commands it is giving dependency error. Commented Jun 17, 2020 at 4:49

1 Answer 1

2

Laravel provides a helper function, asset(), which generates a URL for your assets. You can use this in blade syntax.

Put your css, js files on public folder. for example of a css file, put it on :

../public/bootstrap/css/bootstrap.min.css

In your blade you can access this file from header like this :

<link href="{{ asset('bootstrap/css/bootstrap.min.css') }}" rel="stylesheet" type="text/css" >

hope this help

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

1 Comment

It worked. It might be because of the css files were mentioned using url() function but I changed it to asset(). It worked.

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.