webvimark / user-management

154 stars 163 forks source link

fresh install basic app and user-management doesn't work #44

Closed glanisko closed 9 years ago

glanisko commented 9 years ago

after fresh install of yii2-app-basic, added user-management plugin - installed it as in instruction... and there is a problem:

ReflectionException Class webvimark\modules\UserManagement\components\GhostAccessControl does not exist

<?php

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

$config = [
    'id' => 'basic',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'language' => 'pl-PL',
    'name' => 'Base',
    'components' => [
        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => 'gAry7SfUr0oOjNQDqItsobmGBcJajQoW',
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        'user' => [
            'class' => 'webvimark\modules\UserManagement\components\UserConfig',
            'identityClass' => 'app\models\User',
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        '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'],
                ],
            ],
        ],
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
        ],
        'db' => require(__DIR__ . '/db.php'),
    ],
    'params' => $params,
    'modules'=> [
        'user-management' => [
            'class' => 'webvimark\modules\UserManagement\UserManagementModule',
        ],
    ],
];

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

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = 'yii\gii\Module';

    $config['modules']['utility'] = [
        'class' => 'c006\utility\migration\Module'
    ];
}

return $config;
webvimark commented 9 years ago

Hi, first you should remove 'identityClass' => 'app\models\User', from 'user' component Second, show me your error page please

glanisko commented 9 years ago

identityClass deleted;

git diff after whole process ;)

diff --git a/composer.json b/composer.json
index 99161eb..e06e523 100644
--- a/composer.json
+++ b/composer.json
@@ -13,6 +13,7 @@
         "source": "https://github.com/yiisoft/yii2"
     },
     "minimum-stability": "dev",
+    "prefer-stable": true,
     "require": {
         "php": ">=5.4.0",
         "yiisoft/yii2": "*",
diff --git a/config/console.php b/config/console.php
index 31ed9c7..dd1bae1 100644
--- a/config/console.php
+++ b/config/console.php
@@ -12,6 +12,9 @@ return [
     'controllerNamespace' => 'app\commands',
     'modules' => [
         'gii' => 'yii\gii\Module',
+        'user-management' => [
+            'class' => 'webvimark\modules\UserManagement\UserManagementModule',
+        ],
     ],
     'components' => [
         'cache' => [
diff --git a/config/web.php b/config/web.php
index 48f76f2..2df2884 100644
--- a/config/web.php
+++ b/config/web.php
@@ -17,8 +17,7 @@ $config = [
             'class' => 'yii\caching\FileCache',
         ],
         'user' => [
-            'identityClass' => 'app\models\User',
-            'enableAutoLogin' => true,
+            'class' => 'webvimark\modules\UserManagement\components\UserConfig',
         ],
         'errorHandler' => [
             'errorAction' => 'site/error',
@@ -46,6 +45,11 @@ $config = [
         'db' => require(__DIR__ . '/db.php'),
     ],
     'params' => $params,
+    'modules'=> [
+        'user-management' => [
+            'class' => 'webvimark\modules\UserManagement\UserManagementModule',
+        ],
+    ],
 ];

 if (YII_ENV_DEV) {
diff --git a/controllers/SiteController.php b/controllers/SiteController.php
index f959941..0aea4e2 100644
--- a/controllers/SiteController.php
+++ b/controllers/SiteController.php
@@ -14,16 +14,8 @@ class SiteController extends Controller
     public function behaviors()
     {
         return [
-            'access' => [
-                'class' => AccessControl::className(),
-                'only' => ['logout'],
-                'rules' => [
-                    [
-                        'actions' => ['logout'],
-                        'allow' => true,
-                        'roles' => ['@'],
-                    ],
-                ],
+            'ghost-access'=> [
+                'class' => 'webvimark\modules\UserManagement\components\GhostAccessControl',
             ],
             'verbs' => [
                 'class' => VerbFilter::className(),

and error page: pobrane

webvimark commented 9 years ago

Hmmm, check please vendor\webvimark\module-user-management\components folder and make sure that file GhostAccessControl.php is there =) My only guess so far that module wasn't really installed.

Btw, does migrations worked fine ?

glanisko commented 9 years ago

files are in filesystem ;)

c:\htdocs\base\vendor>dir webvimark\module-user-management\components
 Katalog: c:\htdocs\base\vendor\webvimark\module-user-management\components

2015-04-13  09:14    <DIR>          .
2015-04-13  09:14    <DIR>          ..
2015-04-13  09:14             8 970 AuthHelper.php
2015-04-13  09:14             2 627 GhostAccessControl.php
2015-04-13  09:14               684 GhostHtml.php
2015-04-13  09:14             1 279 GhostMenu.php
2015-04-13  09:14             1 279 GhostNav.php
2015-04-13  09:14             1 381 UserAuthEvent.php
2015-04-13  09:14               997 UserConfig.php
2015-04-13  09:14             4 040 UserIdentity.php
               8 plik(ów)             21 257 bajtów

and migrations doesn't work as well:

c:\htdocs\base>yii migrate --migrationPath=vendor/webvimark/module-user-management/migrations/
[13.04.2015 10:33:07 p284/t6976 NOTICE] Successfully established connection to the database
Yii Migration Tool (based on Yii v2.0.3)

Total 10 new migrations to be applied:
        m140608_173539_create_user_table
        m140611_133903_init_rbac
        m140808_073114_create_auth_item_group_table
        m140809_072112_insert_superadmin_to_user
        m140809_073114_insert_common_permisison_to_auth_item
        m141023_141535_create_user_visit_log
        m141116_115804_add_bind_to_ip_and_registration_ip_to_user
        m141121_194858_split_browser_and_os_column
        m141201_220516_add_email_and_email_confirmed_to_user
        m141207_001649_create_basic_user_permissions

Apply the above migrations? (yes|no) [no]:yes
*** applying m140608_173539_create_user_table
Exception: Class webvimark\modules\UserManagement\UserManagementModule does not exist (C:\htdocs\base\vendor\yiisoft\yii2\di\Container.php:415)
#0 C:\htdocs\base\vendor\yiisoft\yii2\di\Container.php(415): ReflectionClass->__construct('webvimark\\modul...')
#1 C:\htdocs\base\vendor\yiisoft\yii2\di\Container.php(358): yii\di\Container->getDependencies('webvimark\\modul...')
#2 C:\htdocs\base\vendor\yiisoft\yii2\di\Container.php(151): yii\di\Container->build('webvimark\\modul...', Array, Array)
#3 C:\htdocs\base\vendor\yiisoft\yii2\BaseYii.php(344): yii\di\Container->get('webvimark\\modul...', Array, Array)
#4 C:\htdocs\base\vendor\yiisoft\yii2\base\Module.php(354): yii\BaseYii::createObject(Array, Array)
#5 C:\htdocs\base\vendor\webvimark\module-user-management\migrations\m140608_173539_create_user_table.php(16): yii\base\Module->getModule('user-management')
#6 C:\htdocs\base\vendor\yiisoft\yii2\db\Migration.php(81): m140608_173539_create_user_table->safeUp()
#7 C:\htdocs\base\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(492): yii\db\Migration->up()
#8 C:\htdocs\base\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(129): yii\console\controllers\BaseMigrateController->migrateUp('m140608_173539_...')
#9 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#10 C:\htdocs\base\vendor\yiisoft\yii2\base\InlineAction.php(55): call_user_func_array(Array, Array)
#11 C:\htdocs\base\vendor\yiisoft\yii2\base\Controller.php(151): yii\base\InlineAction->runWithParams(Array)
#12 C:\htdocs\base\vendor\yiisoft\yii2\console\Controller.php(91): yii\base\Controller->runAction('', Array)
#13 C:\htdocs\base\vendor\yiisoft\yii2\base\Module.php(455): yii\console\Controller->runAction('', Array)
#14 C:\htdocs\base\vendor\yiisoft\yii2\console\Application.php(161): yii\base\Module->runAction('migrate', Array)
#15 C:\htdocs\base\vendor\yiisoft\yii2\console\Application.php(137): yii\console\Application->runAction('migrate', Array)
#16 C:\htdocs\base\vendor\yiisoft\yii2\base\Application.php(375): yii\console\Application->handleRequest(Object(yii\console\Request))
#17 C:\htdocs\base\yii(23): yii\base\Application->run()
#18 {main}
*** failed to apply m140608_173539_create_user_table (time: 0.111s)

Migration failed. The rest of the migrations are canceled.

c:\htdocs\base>
webvimark commented 9 years ago

Did you install it via composer? If you do, then I'm out of ideas. For some reason composer autoloader could not find clasess.

glanisko commented 9 years ago

yes, it's installed via composer :D I know it's weird situation... :)

webvimark commented 9 years ago

And did you try to install via composer and use any other extensions ? If not try to install something from yii2 extenisons

glanisko commented 9 years ago
    "c006/yii2-migration-utility": "dev-master"

and works perfectly ;)

webvimark commented 9 years ago

Then I really have no idea, sorry =)

glanisko commented 9 years ago

after few hours of finding the bug I have no idea too :) maybe later i will find what's wrong ;)

glanisko commented 9 years ago

oook. its weird:


    'webvimark\\modules\\UserManagement\\' => array($vendorDir . '/webvimark/module-user-management'),
    'webvimark\\image\\' => array($vendorDir . '/webvimark/image'),
    'webvimark\\helpers\\' => array($vendorDir . '/webvimark/helpers'),
    'webvimark\\extensions\\GridPageSize\\' => array($vendorDir . '/webvimark/grid-page-size'),
    'webvimark\\extensions\\GridBulkActions\\' => array($vendorDir . '/webvimark/grid-bulk-actions'),
    'webvimark\\extensions\\DateRangePicker\\' => array($vendorDir . '/webvimark/date-range-picker'),
    'webvimark\\extensions\\BootstrapSwitch\\' => array($vendorDir . '/webvimark/bootstrap-switch'),
    'webvimark\\components\\' => array($vendorDir . '/webvimark/components'),

this was missing part in /vendor/composer/autoload_psr4.php

but I don't know why it wasn't added by composer? ;)

webvimark commented 9 years ago

And it's working now? @_@

glanisko commented 9 years ago

yes, it is now working ;)

webvimark commented 9 years ago

Nice ! I'll post it somewhere, because you are not the first one who met this problem :)