phpyiiyii2

CSS files are not working in server using yii2


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',
    ];
}

Solution

  • 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.