Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Laravel 4 Basics Project Setup Templates and Layouts

bruce zhang
bruce zhang
1,317 Points

Can not load CSS

Hi

I did a route like below: Route::get('/hello/{name?}/{email?}', function($name = 'world',$email = 'world@www.com') { $data = [ 'name'=>$name, 'email'=>$email ]; return View::make('hello1')->with($data); });

and Hello page css link like below: <link rel="stylesheet" href="./css/foundation.css">

however when I load page for testing by the url:

zihai.dev:8000/hello/bruce/bruce@hotmail.com

it says the css not found, then I see the css get url is

http://zihai.dev:8000/hello/bruce/css/foundation.css

looks like it's not point to public/css

how can I make that work?

Thanks Bruce

3 Answers

There is a Laravel keyword to access the css/js.. search for it in laravel site. i think it might be set in config files..

bruce zhang
bruce zhang
1,317 Points

ha, got it

can use public_path

Than you :)

Suggest you use Request::root() and remember to do the .JS <script> tag too or you are losing a lot of functionality

<link rel="stylesheet" href="<?php Request::root() ?>/css/foundation.css" />
<script src="<?php Request::root() ?>/js/vendor/modernizr.js"></script>
Anthony c
Anthony c
20,907 Points

none of these are working for me