I am new in laravel. I setup laravel 5.7 on my local system and put js and css into public folder but when hitting my site url on browser, site is not loading any css and js.
Site structure :
app
bootstrap
config
database
public
-css
-js
-images
resources
-views
-includes
-layouts
-pages
routes
tests
vendor
index.php
server.php
.env
Note : I have cut .htaccess and index.php files and put these on root to run site without public in path.
Here is how I am calling url : CSS :
{{ URL::asset('css/style.css') }}
JS :
{{ URL::asset('js/query-1.11.1.min.js') }}
When seeing source code, the url looks like this :
http://localhost/mysite/css/style.css
So can anybody help me out from this issue ?
Thanks in advance.
The asset()
helper prepends the base URL to the path you supply.
The base URL is the location of index.php (in this case: http://localhost/mysite/).
If you don't want index.php inside /public you will need to use public/ inside your asset path, like this:
asset("public/css/style.css")
Same for the js files, I hope you understand.