i have installed Laravel 5.4 in localhost. I'm using XAMPP to host the application. I'm using Laravel's inbuilt Blade template structure to show the data. I have used asset() helper to load my assets files which is inside the public folder. A sample code is here.
<link href="{{URL::asset('backend/vendors/bootstrap/dist/css/bootstrap.min.css')}}" rel="stylesheet" type="text/css">
But CSS file is not loading. I discovered this from Chrome developer tool's Network section. I have worked with Laravel before with it's other version and this is the first time that i'm working with version 5.4. Hope someone will assist me to solve this.
you can use only asset function like this i hope you have css folder inside public folder as mentioned in the path.
<link href="{{asset('backend/vendors/bootstrap/dist/css/bootstrap.min.css')}}" rel="stylesheet" type="text/css">
asset()
Generate a URL for an asset using the current scheme of the request (HTTP or HTTPS):
Ref: https://laravel.com/docs/5.4/helpers
Related
I have my Laravel project that is hosted on a server, I made a copy of that project for testing and development on my local pc, but there is a difference that I don't know how to solve. On my local pc I do not need to specify public folder to access css files and other stuff, but on my server I have to specify, otherwise I doesn't find those files in public folder.
Example code on server:
<link rel="stylesheet" href="/public/css/main.css">
And on my local pc
<link rel="stylesheet" href="/css/main.css">
So I would love to make this thing the same on my local project, because now everytime I push changes to the server I need to add public to all the stuff and that's annoying. If I understand correctly it is done for security purposes, but I don't know how to make it on my project.
Use Laravel asset() function like below,
<link rel="stylesheet" href="{{asset('css/main.css')}}">
I was given a Laravel project and I manage to download it's configuration and get it started on php artisan serve.
When I open it on localhost:8000 It opens but only the html portion of it.
It seems like css files didn't load for it.
Is there some sort of package we need to install with composer in my environment.
To get the css working.
The public folder looks like this in the laravel project.
backend favicon.ico front images index.html index.php js robots.txt sql vendor
web.config
Laravel provides a helper function, asset(), which generates a URL for your assets. You can use this in blade syntax.
Put your css, js files on public folder. for example of a css file, put it on :
../public/bootstrap/css/bootstrap.min.css
In your blade you can access this file from header like this :
<link href="{{ asset('bootstrap/css/bootstrap.min.css') }}" rel="stylesheet" type="text/css" >
hope this help
So I'm very new to Laravel and I'm following a tutorial to use the authentication feature. This works fine, however it is unable to find my scripts and stylesheets. I haven't made any new ones nor have I touched the stylesheet link in app.blade.php, so I have no clue why it is throwing this error.
Code:
<link href="{{ URL::asset('css/app.css') }}" rel="stylesheet">
Error:
GET http://localhost:8000/css/app.css net::ERR_ABORTED 404 (Not Found)
When I go to locahost/css/app.css I get a 404 error. The same error is occurring with app.js. I haven't changed anything about the file structure and it was all generated with composer create-project laravel/laravel
Thanks.
Laravel doesn't include any CSS files by default. You need to create one yourself and put it to /public/ directory, so in your case that would be /public/css/app.css.
Does localhost point to public in your project? Usually you would have to open http://localhost/public
Per default, URL::asset('css/app.css') expects a css file at /public/css/app.css -- for your setup (serving throught php artisan serve, I suppose?), that would be http://localhost:8000/public/css/app.css.
Anyway: If there is no stylesheet, just create one. There is tons of ways how to do it, depending on your needs. Creating one manually for one, but for complex sites think about using laravel mix for compilation. Or anything other way!
Make sure your style exists at public/css directory, then try this code:
<link rel="stylesheet" href="{{asset('css/app.css')}} type="text/css"/>
if the file doesn't exist, create that and try again.
I hope this can help you.
I am trying to upload a laravel project to cpanel hosting server. My laravel version is 5.3 and php version on the server is 5.6.
What I have done is:
Create a folder called "online_system" to root of file manager.
Copy contents of laravel project except public folder.
Create a folder called "online_system" to public_html.
Copy contents of public folder of laravel project.
Jump to index.php file.
Edit require __DIR__.'/../../online_system/bootstrap/autoload.php';
Edit $app = require_once __DIR__.'/../../online_system/bootstrap/app.php';
Change .env to link DB.
Open domain/online_system.
Home page is working fine, but as long as I click login or register provided by laravel, then the website looks plain without css load.
How can I solve this problem?
Give it a try
<link rel="stylesheet" type="text/css" href="{{ url('online_system/css/styl.css') }}" />
I guess this will do the trick:
<link rel="stylesheet" type="text/css" href="/public/css/style.css"/>
If your project is on the server and change your views, So clear view cache:
php /path_to_your_project/ artisan view:clear
I am currently using Laravel 5.2 framework for my web dev project and stuck on problem. In my dashboard.blade.php i want specify the link to an external css file which is in public/src/css/main.css.
I used URL::to() and URL::asset() methods to get the absolute path to the CSS file but still it is not working.
When i placed my CSS file just inside the public directory everything worked fine but when i place it inside any subdirectory in the public directory it doesnot work.
I am homestead along with the laravel as development environment.
dashboard.blade.php file
directory structure of the project
Please put your css in public folder
<link type="text/css" rel="stylesheet" href="{{ asset('css/style.css')}}">
No matter where you place your css file inside public folder you can get it using the code :
<link rel=stylesheet" href="{{asset('src/css/main.css')}}">
For this code place your css file inside public/src/css
In your image of directory there is no folder as css inside src