Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel assets url

I have installed Laravel and began trying to write an app. I made some directories for my assets in the same directory as /app. But when I try to visit an image in my localhost for example: http://localhost/assets/images/image.png

I've also tried it on: http://localhost/app/assets/images/image.png

I ran into the problem when I was trying to set a background image in a view, and it kept going to 404.

This is what my app looks like under app/

->app ->assets ->commands ->config ->controllers ->database ->lang ->models ->start ->storage ->tests ->views app.txt routes.php filters.php 

But I get errors about requests. I have double checked that the url is correct.

Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException 
like image 855
vikingcode Avatar asked Jul 17 '14 03:07

vikingcode


People also ask

What is URL :: asset in laravel?

{{url}} allows you to create a link to a URL on your site -- another benefit is the fact that you can set the second parameter to an array with query string parameters within. {{asset} simply allows you to link to an asset within your public directory -- for example css/main.

What is assets URL?

Asset/app links are URLs to a piece of content, a folder, or an Experience in Showpad. You can use them in any type of document, as long as you make sure you export the document as a PDF file or as an HTML web app. These links are convenient for linking content from an asset or an HTML app to another asset.

Where is assets in laravel?

The assets folder in the resources directory is for files that need compilation, like views or LESS files. Compiled assets, or plain assets like CSS and JS files should be in public/assets/ .


1 Answers

You have to put all your assets in app/public folder, and to access them from your views you can use asset() helper method.

Ex. you can retrieve assets/images/image.png in your view as following:

<img src="{{asset('assets/images/image.png')}}">

like image 85
Walid Ammar Avatar answered Sep 19 '22 20:09

Walid Ammar