1

I integrated the CSS and JS file in the asset file. On localhost it's working but when I uploaded my project files in cPanel, the UI is breaking. I can't understand where I'm making the mistake, please help me fix these issues.

Inside the backend folder, I uploaded my AdminLTE-2 CSS and JS files in the web folder. In the asset layout file, I gave the path.

backend/assets/loginAsset.php

namespace backend\assets;

use yii\web\AssetBundle;

/**
 * Main backend application asset bundle.
 */
class loginAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = [
        'bower_components/bootstrap/dist/css/bootstrap.min.css',
        'bower_components/font-awesome/css/font-awesome.min.css',
        'bower_components/Ionicons/css/ionicons.min.css',
        'css/AdminLTE.min.css',
        'plugins/iCheck/square/blue.css',
        '//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic',
        //'css/site.css',
    ];

    public $js = [
        '//oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js',
        '//oss.maxcdn.com/respond/1.4.2/respond.min.js',
        'bower_components/jquery/dist/jquery.min.js',
        'bower_components/bootstrap/dist/js/bootstrap.min.js',
        'plugins/iCheck/icheck.min.js',
    ];
    public $depends = [
        //'yii\web\YiiAsset',
        //'yii\bootstrap\BootstrapAsset',
    ];
}
5
  • Hi, can you check if file is exists in server and you have permission to read file? (I think its file permission issue) Also make sure your css path inside direction: Asset_Management/backend/web/css/AdminLTE.min.css Commented Feb 17, 2020 at 15:54
  • localhost also the same folder it's working there but not working and the folder permission also 755 Commented Feb 17, 2020 at 15:59
  • What about file permission? Also is shared hosting or not? Commented Feb 17, 2020 at 16:00
  • I find out the issue that is a spelling mistake in server adminlte.min.css but I gave the AdminLTE.min.css Commented Feb 17, 2020 at 16:03
  • ues, thats true, since its exsits assetman.gunwebhosting.com.au/Asset_Management/backend/web/css/… like this :D Commented Feb 17, 2020 at 16:04

2 Answers 2

1

Depending on your code, the issue is usually one of these scenarios:

  1. File doesn't exist in Asset_Management/backend/web/css/AdminLTE.min.css
  2. File does not have a truth permission.
  3. Maybe you need to add a truth server configuration to handling Asset_Management since by default it must be backend/web/css/AdminLTE.min.css nested of Asset_Management/backend/web/css/AdminLTE.min.css
  4. File Name is wrong, spelling mistake.
Sign up to request clarification or add additional context in comments.

1 Comment

Yes your correct it's spilling mistake inside the server file name is simple letters but in URL I call capital letters. that is the issues
0

There is a fifth reason why you may not have any css. At the top of route\to\your\site\frontend\views\layouts\main.php or route\to\your\site\web\views\layouts\main.php there must be the following:

AppAsset::register($this);

Above this you should “use” the class, so either use frontend\assets\AppAsset; for advanced yii2 or use app\assets\AppAsset; for the yii2 basic. If you don’t register your CSS there is no CSS.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.