Jump to content

links wont work on laravel


I-AM-OBODO

Recommended Posts

Hi all.

 

No matter what i tried my links just wont work on my laravel app.  My css folder is in the public folder. public/css. I dunno what is wrong. I installed laravel with composer and i am running windows 7 and wamp.

this is the link i used:

 

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

 

Thanks

Link to comment
Share on other sites

What URL is it trying to load? Look in the network tab on Chrome Developer Tools.

 

On the network tab in chrome it's not showing any url at all. just blank but on view source

 

localhost/laravel/index

localhost/laravel/css/styles.css

localhost/laravel/css/bootstrap.min.css

localhost/laravel/css/bootstrap-theme.min.css

localhost/laravel/js/bootstrap.min.js

 

again i noticed it has 8 error notifications and when i checked, i saw that the path to my styles is not seen:

Failed to load resource: the server responded with a status of 404 (Not Found)

 

what could be wrong. but when i load the bootstrap style from the cdn, it works perfectly!!

Edited by Mr-Chidi
Link to comment
Share on other sites

If your assets are in public/css, and it's only loading css, then it looks like you should change the asset path to include public.

 

<link rel="stylesheet" href="{!! asset('public/css/bootstrap.min.css') !!}">
<link rel="stylesheet" href="{!! asset('public/css/styles.css') !!}">
Link to comment
Share on other sites

If your assets are in public/css, and it's only loading css, then it looks like you should change the asset path to include public.

 

<link rel="stylesheet" href="{!! asset('public/css/bootstrap.min.css') !!}">
<link rel="stylesheet" href="{!! asset('public/css/styles.css') !!}">

Tried it as well but to no avail :(

Link to comment
Share on other sites

My directory structure

app

- Console

-Events

- Exeptions

- Http

- Jobs

- Listeners

- Policies

- Providers

-- user

bootstrap

- cache

-- app

-- autoload

config

-- app

-- auth

-- broadcasting

-- cache

-- compile

-- database

-- filesystems

-- mail

-- queue

-- services

-- session

-- view

database

- factories

- migrations

- seeds

public

- css

- fonts

- js

-- htaccess

-- favicon

-- index

-- robots

resources

- assets

- lang

- views

storage

- app

- framework

- logs

tests

- ExampleTest

- TestCase

vendor

- so many folders

Edited by Mr-Chidi
Link to comment
Share on other sites

So if you point your browser to localhost/laravel/public/css/styles.css, it doesn't work?

 

Can you post your directory structure?

 

My directory structure

app

- Console

-Events

- Exeptions

- Http

- Jobs

- Listeners

- Policies

- Providers

-- user

bootstrap

- cache

-- app

-- autoload

config

-- app

-- auth

-- broadcasting

-- cache

-- compile

-- database

-- filesystems

-- mail

-- queue

-- services

-- session

-- view

database

- factories

- migrations

- seeds

public

- css

- fonts

- js

-- htaccess

-- favicon

-- index

-- robots

resources

- assets

- lang

- views

storage

- app

- framework

- logs

tests

- ExampleTest

- TestCase

vendor

- so many folders

Link to comment
Share on other sites

  • 3 months later...

If your CSS files are not loaded properly then Laravel doesn’t know where to look for them.

To let Laravel know where your CSS file is located you’ll need to set a direct path in your blade file:

 {!! HTML::style('_asset/css/custom.css') !!}



It looks very similar for javascript files:

  {!! HTML::script('_asset/js/jquery.min.js') !!}



If this doesn’t work, or you’ll get an error that the HTML serviceprovider class is missing, you’ll need to install the illuminate/html package.

This is how you do it:

Add the following line in the require section of composer.json file

 "require-dev": {
        "illuminate/html": "5.*",


And run composer update.

Register the service provider in config/app.php by adding the following value into the providers array:

        Illuminate\Html\HtmlServiceProvider::class


And finally register the facades by adding these two lines in the aliases array:

        'Form'=> 'Illuminate\Html\FormFacade',
        'HTML'=> 'Illuminate\Html\HtmlFacade'

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.