css files in Laravel 4

Asked

Viewed 2,678 times

4

I’m starting with Laravel and I don’t know where to put the css files, since there is no Assets folder, as there is in Laravel 5. I need to work with version 4, because the PHP version on the server is old and I can’t change. I couldn’t find anything on Google that would help me.

2 answers

4


Put your css in the briefcase project/public/css/.

To call in your template file Blade can be like this:

<link href="{{ asset('css/app.css') }}" rel="stylesheet"> 

or

{{ HTML::style( asset('css/app.css') ) }}
  • And you need to call css on every page?? I usually use a 4 different css, I’ll have to call them all on every page or is there some way to call just once for the whole project?

  • 1

    @Amandalima, then you could use the layout structure of the Laravel for this. You create a layout with everything you use and extend it with the view.

  • Thank you very much!!

  • 1

    you can put in a file called template and on the other pages inherit it using extends, in the documentation you have all the step by step how to do:http://laravel.com/docs/4.2/templates

3

Amanda, you just need to put them in the folder public of the application.

You can create a folder for each document/script type you will use.

Example:

public/css
public/js

I don’t usually use the function asset, because the generated path would literally be as if the application were in public.

For an example javascript file that would be in public/js we could do yes.

public/js/jquery.js

It could be inserted into the code simply like this:

{{ HTML::script('js/jquery.js') }}
  • 1

    I also do so. Without the function asset.

  • 1

    @Deesouza, I would call this unnecessary additional processing

Browser other questions tagged

You are not signed in. Login or sign up in order to post.