@panto

Как решить проблему с переносом yii2 на хостинг?

Доброе время суток. Я уже 2 день ищу решение проблемы, может кто-нибудь сможет помочь.
Использовал вот этот вот модуль для контроля доступа в yii2 https://github.com/mdmsoft/yii2-admin
На локальном сервере все работало, переходило по site.ru/rbac. На хостинге выдает ошибку
Unknown Class – yii\base\UnknownClassException

Использовал .htaccess в папке /web
# Mod_Autoindex
<IfModule mod_autoindex.c>
# Disable indexes
Options -Indexes
</IfModule>

# Mod_Rewrite
<IfModule mod_rewrite.c>
# Enable symlinks
Options +SymLinksIfOwnerMatch
# Enable mod_rewrite
RewriteEngine On

# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
</IfModule>


И .htaccess в корне
# Mod_Autoindex
<IfModule mod_autoindex.c>
# Disable Indexes
Options -Indexes
</IfModule>

# Mod_Rewrite
<IfModule mod_rewrite.c>
# Enable symlinks
Options +SymLinksIfOwnerMatch
# Enable mod_rewrite
RewriteEngine On

# Redirect all requests to web
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteRule ^(.*)$ web/$1
</IfModule>


Так же не отображаются контроллеры модуля admin кроме default, его он выводит нормально, но если попытаться перейти допустим на admin/edit, то выводит такую же ошибку как и с rbac.

файл config/web
<?php

$params = require(__DIR__ . '/params.php');

$config = [
    'id' => 'basic',
    'language' => 'ru',

    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'components' => [
        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => 'eSF2bcJ',
            'baseUrl'=> '',
        ],
        'authManager' => [
            'class' => 'yii\rbac\DbManager', // or use 'yii\rbac\DbManager'
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        'user' => [
            'identityClass' => 'app\models\User',
            'loginUrl' => ['site/login'],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'urlManager'=> [
            'class' => 'yii\web\UrlManager',
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                '<controller:\w+>/<id:\d+>'=>'<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
                '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
            ],
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            // send all mails to a file by default. You have to set
            // 'useFileTransport' to false and configure a transport
            // for the mailer to send real emails.
            'useFileTransport' => true,
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'db' => require(__DIR__ . '/db.php'),
        /*
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
            ],
        ],
        */
    ],
    'modules' => [
        'admin' => [
            'class' => 'app\modules\admin\Module',
            ],
        'rbac' => [
            'class' => 'mdm\admin\Module',
            'controllerMap' => [
                'assignment' => [
                    'class' => 'mdm\admin\controllers\AssignmentController',
                    /* 'userClassName' => 'app\models\User', */
                    'idField' => 'user_id',
                    'usernameField' => 'username',
                ],
            ],
            'layout' => 'left-menu',
            'mainLayout' => '@app/views/layouts/admin.php',
        ],
    ],
    'as access' => [
        'class' => 'mdm\admin\components\AccessControl',
        'allowActions' => [
            'site/*',
            'admin/*',
            'rbac/*',
        ]
    ],
    'params' => $params,
];

if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
    ];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
    ];
}

return $config;
  • Вопрос задан
  • 436 просмотров
Пригласить эксперта
Ответы на вопрос 1
shoxabbos1994
@shoxabbos1994
Junior proger
Nu znachit file UnknownClassException otsustvuet!
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы