why I need public word when i live my Laravel project - laravel

hello Laravel developers!
I am stuck with Laravel assets URLs.
<link href="/css/app.css" rel="stylesheet">
this link works fine on localhost.
But why i need to add "public" when i upload it to server like
<link href="/public/css/app.css" rel="stylesheet">
I moved app/public/index.php to app/index.php and make changes in server.php and index.php accordingly. Rest is the working fine. issue is only with assets urls.
Similarly, the class
.edu-home-hero-area {
background: url(/assets/images/curve.webp) !important;
}
works fine on localhost but when i upload it, it does not work i need to change it to
.edu-home-hero-area {
background: url(/public/assets/images/curve.webp) !important;
}
please have a look
https://pdaofficial.com/
any help would be appreciated

I'm not sure if i understand your question completely but you should not be moving public folder files some where else. why not reference your css or js assets using asset function. It will directly point to public folder and look for build.css inside css folder.
<link type="text/css" rel="stylesheet" href="{{ asset('css/build.css') }}">

Related

LARAVEL 9: I cannot reach my css file code anytime i have a doube url like this : /user/profile. How can i solve this?

LARAVEL 9: I am using a template in Laravel 9 and I cannot reach my CSS file code anytime I have a double URL like this : /user/profile. However, It only works when I have a single URL like this: /profile. But I want to be able to reach my CSS files when I have double URLs. How can I solve this? Any suggestions?
Did you put the files correctly in the public folder?
Do you invoke it correctly within the blade as the following example:
<link href="{{URL::asset('assets/plugins/fontawesome-free/css/all.min.css')}}" rel="stylesheet">
Have you checked the error by inspecting your browser?
You can check this link contains many useful examples for your case
Put a slash "/" at the beginning of the css address. For example if you have somethin like this:
<link rel="stylesheet" type="text/css" href="css/style.css">
Change it to this:
<link rel="stylesheet" type="text/css" href="/css/style.css">

laravel localhost and server work different with htaccess and public folder

After removing .htaccess from public to main, and renaming server.php to index.php all Asset links and links from the css background-image are wrong.
Is there a way to either have the same problem on localhost (the /public in the url) or is there an other easy fix? Cause right now if I fix my code on my online server, it doesn't work locally anymore and vise versa.
External CSS, Images and JS
Example Here,
Your URL Like:
For CSS
<link rel="stylesheet" type="text/css" href="{{url('/public/file_name.css')}}">
For JS
<script type="text/javascript" src="{{url('/public/file_name.js')}}">
After domain name, you must use public and then your CSS, images, and js path.

Newly installed laravel 5.2 wont read linked css

I have installed a Laravel 5.2 to run an existing project from my group mates but in my laptop, the project will only read inline CSS, it cannot read Linked CSS, What seems to be the problem?
you should use helper
url('path/to/css/file/in/public/folder')
First, put your assets in the public folder
Then you can use:
<link href="{{ url('path/file.css')}}" rel="stylesheet" type="text/css" />

Problems with Lumen 5.2

I recently installed Laravel 5.2 and i´ve been experiencing some problems loading css and js files from the project public folder.
I have all my views on the resources folder and my asset files on the public folder, i tried installing html collective but is not working.
Could someone please help me link the css and js files, so they load.
This is my view:
<link href="assets/css/style.css" rel="stylesheet">
<link rel="stylesheet" href="/css/app.css" />
You can use the asset helper:
$url = asset('img/photo.jpg');
Cf docs: https://laravel.com/docs/5.2/helpers#method-asset

Where to put css file in laravel project

I have been searching for an answer to this question with no luck. This is my second day using laravel and I'm trying to create a custom 404 error page. I don't know where/how to include my .css file. Can someone please help me with this?
Place your css files inside public folder and use link tag in html document (or 404 template)
Example
<link rel="stylesheet" type="text/css" href="{{ url('/css/style.css') }}" />
The best way is using blade syntax with the laravel helper for what you need
<link rel="stylesheet" href="{{ asset('css/style.css') }}">
this folder css or whatever you named it, must be placed inside your public folder.
Search for Public folder in Laravel.
Create css folder (that contains stylesheet files of your project), javascript and Images folder (contains images that you will use in your project).
Go to layouts in app.blade.php file update html code using blade syntax:
<link rel="stylesheet" href="{{ asset('css/style.css') }}">
and JS:
<script src="{{ asset('pickadate/lib/picker.js')}}"></script>
1. put your CSS file in directory [PUBLIC/CSS]
2. in your FileName.blade.php in file just write :
<head> <link rel="stylesheet" href={{ asset('css/article.css')}}> </head>
Note Again : Don't Write asset('public/css/article.css') this wrong
put it in your public file and the html tags in view then to connect them with the css use
<link rel="stylesheet" href="{{ URL.asset('css/style.css') }}">
<link rel="stylesheet" href="css/app.css">
simply add this your blade.php file

Resources