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
Related
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
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
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
I created a versioned css file using:
elixir(function(mix) {
mix.sass('demo.scss')
.version('css/demo.css');
});
the file is under public/build/demo-34f5737738.css, according to the documentation the file should be linked this way:
<link rel="stylesheet" href="{{ elixir("css/demo.css") }}"
however the stylesheet is not being applied when running in Xampp, but it's working when I start a server via command: php artisan serve.
Any idea of why this is happening, or does Xampp needs a special setup before working with Laravel. Thanks!
Setting absolute path via asset will solve that issue:
<link rel="stylesheet" href="{{ issue("css/demo.css") }}"
I am new to Laravel and am trying to get the css in the public directory to load. The page loads no problem but the CSS gives me a 404 error in firebug:
"NetworkError: 404 Not Found - http://127.0.0.1:8000/css/main.css"
I wrote this in the blade template:
<link href="{{ asset('/css/main.css') }}" rel="stylesheet">
Which outputs:
<link href="http://127.0.0.1:8000/css/main.css" rel="stylesheet">
Which seems correct.
The site is run with php artisan serve. Any suggestions? Thanks!
Try:
<link href="{{asset('css/main.css')}}" rel="stylesheet">
OR
<link href="{{url('css/main.css')}}" rel="stylesheet">
OR
If you are using php artisan serve its possible that your public folder is not being used, so use PHP native server instead and specify the public folder as the web root.
Stop artisan serve and try using PHP native server by issuing this command at the root of your Laravel project: php -S localhost:8000 -t public
If you install Illuminate/HTML
you can do
{!!HTML::style('css/styles.css')!!} //styles.css inside public/css folder
or try
{{ asset('css/styles.css') }}
When you specify a path for your css and JS files, the root of the files need to be in 'project-name\public\' and not 'project-name\'
If you want for example to include with blade 'mytheme.css' which is inside 'mypersonalcss' folder ('mypersonnalcss\mytheme.css') fist add it to the project in 'project-name\public\mypersonnalcss\mytheme.css'
Then add it in your blade file :
<link href="{{ asset('mypersonnalcss\mytheme.css') }}" rel="stylesheet" type="text/css" >
Please see : Laravel 5 not finding css files to learn more about how to add assets to blade files.