как настроить второй модуль в YII

Я настроил yii на локальном хосте с одно имя модуля в качестве администратора.
Теперь я должен добавить еще один модуль с именем store.

в main.php у меня есть:

'import' => array(
'application.models.*',
'application.components.*',
'application.modules.*',
'application.modules.admin.models.*',
'application.modules.store.*',
'application.modules.store.components.*',
'application.modules.store.models.*',
'ext.yii-mail.YiiMailMessage',
'application.extensions.EAjaxUpload.*',
'bootstrap.helpers.*',
'bootstrap.widgets.*',
'bootstrap.components.*',
'ext.EPhpThumb.EPhpThumb',
),
'modules' => array(
'gii' => array(
'class' => 'system.gii.GiiModule',
'password' => 'abcd11',
'ipFilters' => array('127.0.0.1', '::1'),
),
'admin' => array('defaultController' => 'admin'),
'store' => array( 'debug' => true ),
),
// application components
'components' => array(
'request' => array(
),
'ePdf' => array(
'class' => 'ext.yii-pdf.EYiiPdf',
'params' => array(
'mpdf' => array(
'librarySourcePath' => 'application.vendors.mpdf.*',
'constants' => array(
'_MPDF_TEMP_PATH' => Yii::getPathOfAlias('application.runtime'),
),
'class' => 'mpdf', // the literal class filename to be loaded from the vendors folder

),
),
),
'bootstrap' => array(
'class' => 'bootstrap.components.TbApi', // bootstrap configuration
),
'yiiwheels' => array(
'class' => 'yiiwheels.YiiWheels', // yiiwheels configuration
),
'phpThumb' => array(
'class' => 'ext.EPhpThumb.EPhpThumb',
),
'session' => array(
'timeout' => 86400,
),
'user' => array(
'loginUrl' => array('admin/login'),
// enable cookie-based authentication
'allowAutoLogin' => true,
'autoRenewCookie' => true,
'identityCookie' => array('domain' => 'http://localhost'),
'authTimeout' => 86400,
),
// uncomment the following to enable URLs in path-format
'mail' => array(
'class' => 'ext.yii-mail.YiiMail',
'transportType' => 'smtp',
'transportOptions' => array(
'host' => 'localhost',
'username' => '',
'password' => '',
'port' => '25',
),
'viewPath' => 'application.views.mail',
),
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'caseSensitive' => false,
'rules' => array(
'/' => 'admin/',
'page/<id:[0-9]+>/' => 'page/publicPage',
'page/<slug:[a-zA-Z0-9-_\/]+>/' => 'page/view',
'admin' => 'admin/login',
'<slug:' . SLUG_CONTACT_US . '>' => 'page/contact',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
),
// uncomment the following to use a MySQL database
'db' => array(
'connectionString' => 'mysql:host=localhost;dbname=' . $arrConfig['dbName'],
'emulatePrepare' => true,
'username' => $arrConfig['dbUser'],
'password' => $arrConfig['dbPass'],
'charset' => 'utf8',
),
'errorHandler' => array(
// use 'site/error' action to display errors
'errorAction' => '/admin/dashboard/error',
),
'log' => array(
'class' => 'CLogRouter',
'routes' => array(
array(
'class' => 'CFileLogRoute',
'levels' => 'error, warning',
),
),
),
'hybridAuth' => array(
'class' => 'ext.widgets.hybridAuth.CHybridAuth',
'enabled' => true, // enable or disable this component
'config' => array(
"base_url" => $siteUrl . '/hybridauth/endpoint',
"providers" => array(
"Google" => array(
"enabled" => false,
"keys" => array("id" => "", "secret" => ""),
),
),
"debug_mode" => false,
"debug_file" => "",
),
), //end hybridAuth
),

кто-нибудь может помочь?
если потребуется какая-либо другая информация, я отредактирую свой вопрос.

1

Решение

это потому, что ваше приложение не знает, какой модуль загрузить. вам нужно установить class которые ссылаются на класс модуля, который вы хотите загрузить. пример :

'modules' => [
'admin' => [
'class' => 'app\modules\admin\Module',
'defaultController' => 'admin'
],
'gii' => [
'class' => 'yii\gii\Module',
'allowedIPs' => ['127.0.0.1', '::1', '192.168.*.*'],
],
],
1

Другие решения

Чтобы добавить модуль, достаточно добавить его имя в основной конфиг модуля.

Затем вы должны добавить в правило urlManager как '/store' => 'store/guest/index', после этого контроллер guest/index в модуле store будет работать.

В каталоге protected у тебя должно быть:

1) защищенный / modules / store / StoreModule.php

<?php
class StoreModule extends CWebModule
{
}

2) защищенные / модули / магазин / контроллеры / гость / IndexController.php

<?php
class IndexController extends CController
{
public function actionIndex()
{
var_dump(200);
}
}

Пример:

1) Создать новое приложение yii:
php yiic.php webapp testdrive,

2) Применить разница.

3) Запустите приложение: php -S localhost:8002 index.php,

4) Проверьте: curl http://localhost:8002/store

5) Добавить модуль admin. Применять разница.

6) Проверьте: curl http://localhost:8002/admin

1

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector