Support the ongoing development of Laravel.io →
Views Blade
Last updated 2 years ago.
0

Try /css/style.css

Last updated 2 years ago.
0

I tried it and it still didn't work

Last updated 2 years ago.
0

And you are sure that you have the correct path to the file?

Have you tried:

{{ HTML::asset('css/style.css') }}
Last updated 2 years ago.
0

According to this:

http://forumsarchive.laravel.io/viewtopic.php?id=9223

You should try using Html:: instead of HTML.

--- EDIT ---

Forget what I said, looks like it was reverted.


Are you using some layout file?

Last updated 2 years ago.
0

It is the correct path and I tried to use

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

but then I got "Method asset does not exist." error.

The layout that I'm using is one that I'm creating.

Last updated 2 years ago.
0

Hi !

This should be working.

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

your "css" folder is in the public directory right ?

Last updated 2 years ago.
0

I feel so stupid now. It wasn't in the public directory. This whole time I thought it was.

Last updated 2 years ago.
0

hey guys i have the same problem however the css file is loaded correctly in the html document, if i follow the link it event displays the css content but the document doesnt apply any rules?!

in my layout.blade.php

<!-- app/views/layouts/base.blade.php -->

<!DOCTYPE html>
<!--[if lt IE 7]>      <html  prefix="og: http://ogp.me/ns#"  lang="en" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html  prefix="og: http://ogp.me/ns#"  lang="en" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html  prefix="og: http://ogp.me/ns#"  lang="en" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html  prefix="og: http://ogp.me/ns#"  lang="en"  class="no-js"> <!--<![endif]-->
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
    
    	<title  itemprop="name">Test Website</title>
    	
    	@section('css')
        	{{ HTML::style('/assets/css/style.css') }}
    	@show
    </head>
    
    <body itemscope itemtype="http://schema.org/WebPage">
        @include('includes.navigation')
    	@yield('content')
    </body>
</html>
<!-- app/views/home.blade.php -->

@extends('layouts.base')

@section('css')
            
@stop

@section('content')
    <div class="welcome">
	    <h1>You have arrived.</h1>
	    {{ 
	        HTML::image('assets/images/test.jpg', 
	        $alt="This is just a test", 
	        $attributes = array('width'=>'100px')) 
	    }}
    </div>
@stop

firebug displays the following when i try to expand the css:

Reload the page to get source for: http://test-c9-tomek_i.c9.io/assets/css/style.css

you can visit my testupload here: https://test-c9-tomek_i.c9.io/

EDIT:

in the home.blade.php where the CSS section is, there is a @ parent but the forum removes it

EDIT2:

if i use in my layout

<link media="all" type="text/css" rel="stylesheet" href="/public/assets/css/style.css">

it works

Last updated 2 years ago.
0

It seems to me that your Virtual Path in web server (Apache or NGINX or whatever) is not pointing to public folder instead it is pointing to laravel insllation folder? can you check in web server config file, where is the document root pointing to. it should be pathto-laravel\public instead of pathto-laravel

Last updated 2 years ago.
0

Hi,

thanks for the quick response. The path in the web server config is pointing to the www folder, i created a htaccess there to push it then to the public folder

i wanted to have nicer urls and get rid of public and index.php in the urls i am total noob in htaccess and just patched it somehow together based on internet searches, i does what i was looking for but maybe its not 100% correct and it's causing this issue.

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_URI} !^/public/ 

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ /public/$1 
#RewriteRule ^ index.php [L]
RewriteRule ^(/)?$ public/index.php [L] 
</IfModule>
Last updated 2 years ago.
0

In order to have pretty urls you only need to follow this Pretty URLs Apache and it .htaccess file already there in public folder, so you only need to change Apache config file to set web root to public folder, not the folder about it (i.e. exposing all app, bootatrap, public )

Seems like your web root is in wrong place, so I think change the VirtualHost to point to public folder not the installation folder, I'm not expert on htaccess file but I think exposing your entire installation folder as web root is not good idea by any means. we should restrict the access to public folder keeping rest of the logic outside web root at all time.

or if you still want this way, check the bootstrap\paths.php file and change the paths according to your web root. I'm just guessing here.

or else since now your web root is one step above try using following links for css and javascripts

{{ HTML::style('public/css/style.css') }}
Last updated 2 years ago.
0

Hi,

well I am not exposing the root folder where all the private files are (i thought) because i placed that htaccess file in the root path which basically prevents users seeing any of these when browsing to the domain. The htaccess pushes the request forward to the public folder - where the default .htaccess is which came with laravel and is unchanged.

I am using a cloud dev. server (cloud9) i am not sure if i can change the php.ini to serve laravel's public folder instead whatever cloud9's default setting is.

I will try your suggestion and see if it does make any difference and report back.

EDIT Nope, no change at all.

I did change the doc_root in php.ini but it didn't change anything. I tried all combinations of public and / but it didn't push my request to that folder it stayed at the root exposing all of laravel's internal file/folder structures.

and yes, i did save and restart apache after each change :-)

i was not able to find the httpd.conf file on that cloud instance

find / -name httpd.conf

it seems that it's not exposed to accounts just php.ini is

EDIT 2

I placed a phpinfo() on the server, maybe it does shed some more light to it. You can access it here; https://test-c9-tomek_i.c9.io/info.php

p.S. that file is physically located in laravel's public folder!

So the document root is:

/home/ubuntu/workspace

in workspace is laravel placed so the public folder is at this path:

/home/ubuntu/workspace/public

my htaccess listed above is inside the workspace folder, and pushes all requests to public so if somebody access the root where the server would serve /home/ubuntu/workspace/index.php the .htaccess serves /home/ubutnu/workspace/public/index.php

if it makes sense ? :-)

Last updated 2 years ago.
0

I had the same problem using cloud9 and the following method:

HTML::style

It looks like the issue is due to the method generating:

<link media="all" type="text/css" rel="stylesheet" href="http://test-c9-tomek_i.c9.io/assets/css/style.css">

This issue is HTTPS vs HTTP. This can be solved in two (probably more) ways, one of which you've already discovered:

<link media="all" type="text/css" rel="stylesheet" href="/public/assets/css/style.css">

or

{{ HTML::style('https://test-c9-tomek_i.c9.io/public/css/style.css') }}
0

For Laravel 5

{!! HTML::style('css/custom.css')!!}
Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

nicoleg894 nicoleg894 Joined 24 Aug 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.