Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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