Closed danielmeneses closed 9 years ago
Because user
is not defined in console apps, class
is required. In web app it's defined by default so one can override only some properties relying on defaults.
Can you provide full error that appears in the backend app?
hi samdark,
here you go, see bellow. Anyway, what you say make sense, but i thing that is not an expected behavior. I find a little weird set user component on console even if it' will not be used at all!
thanks for the response.
Unknown Property – yii\base\UnknownPropertyException
Setting unknown property: common\models\User::identityClass
1. in /var/www/isdocpal/vendor/yiisoft/yii2/base/Component.php at line 197
188189190191192193194195196197198199200201202203204205206 $behavior->$name = $value;
return;
}
}
}
if (method_exists($this, 'get' . $name)) {
throw new InvalidCallException('Setting read-only property: ' . get_class($this) . '::' . $name);
} else {
throw new UnknownPropertyException('Setting unknown property: ' . get_class($this) . '::' . $name);
}
}
/**
* Checks if a property is set, i.e. defined and not null.
* This method will check in the following order and act accordingly:
*
* - a property defined by a setter: return whether the property is set
* - a property of a behavior: return whether the property is set
2. in /var/www/isdocpal/vendor/yiisoft/yii2/db/BaseActiveRecord.php – yii\base\Component::__set('identityClass', 'common\models\User') at line 266
3. in /var/www/isdocpal/vendor/yiisoft/yii2/BaseYii.php – yii\db\BaseActiveRecord::__set('identityClass', 'common\models\User') at line 518
4. in /var/www/isdocpal/vendor/yiisoft/yii2/base/Object.php – yii\BaseYii::configure(common\models\User, ['identityClass' => 'common\models\User', 'enableAutoLogin' => true]) at line 105
5. yii\base\Object::__construct(['identityClass' => 'common\models\User', 'enableAutoLogin' => true])
6. in /var/www/isdocpal/vendor/yiisoft/yii2/di/Container.php – ReflectionClass::newInstanceArgs([['identityClass' => 'common\models\User', 'enableAutoLogin' => true]]) at line 372
7. in /var/www/isdocpal/vendor/yiisoft/yii2/di/Container.php – yii\di\Container::build('common\models\User', [], ['identityClass' => 'common\models\User', 'enableAutoLogin' => true]) at line 151
8. in /var/www/isdocpal/vendor/yiisoft/yii2/BaseYii.php – yii\di\Container::get('common\models\User', [], ['identityClass' => 'common\models\User', 'enableAutoLogin' => true]) at line 344
9. in /var/www/isdocpal/vendor/yiisoft/yii2/di/ServiceLocator.php – yii\BaseYii::createObject(['class' => 'common\models\User', 'identityClass' => 'common\models\User', 'enableAutoLogin' => true]) at line 133
10. in /var/www/isdocpal/vendor/yiisoft/yii2/di/Instance.php – yii\di\ServiceLocator::get('user') at line 152
11. in /var/www/isdocpal/vendor/yiisoft/yii2/di/Instance.php – yii\di\Instance::get(null) at line 128
12. in /var/www/isdocpal/vendor/yiisoft/yii2/filters/AccessControl.php – yii\di\Instance::ensure('user', 'yii\web\User') at line 98
13. in /var/www/isdocpal/vendor/yiisoft/yii2/base/Object.php – yii\filters\AccessControl::init() at line 107
14. yii\base\Object::__construct(['rules' => [['actions' => ['login', 'error', 'signup', 'request-password-reset'], 'allow' => true], ['actions' => ['logout', 'index'], 'allow' => true, 'roles' => ['@']]]])
15. in /var/www/isdocpal/vendor/yiisoft/yii2/di/Container.php – ReflectionClass::newInstanceArgs([['rules' => [['actions' => ['login', 'error', 'signup', 'request-password-reset'], 'allow' => true], ['actions' => ['logout', 'index'], 'allow' => true, 'roles' => ['@']]]]]) at line 372
16. in /var/www/isdocpal/vendor/yiisoft/yii2/di/Container.php – yii\di\Container::build('yii\filters\AccessControl', [], ['rules' => [['actions' => ['login', 'error', 'signup', 'request-password-reset'], 'allow' => true], ['actions' => ['logout', 'index'], 'allow' => true, 'roles' => ['@']]]]) at line 151
17. in /var/www/isdocpal/vendor/yiisoft/yii2/BaseYii.php – yii\di\Container::get('yii\filters\AccessControl', [], ['rules' => [['actions' => ['login', 'error', 'signup', 'request-password-reset'], 'allow' => true], ['actions' => ['logout', 'index'], 'allow' => true, 'roles' => ['@']]]]) at line 344
18. in /var/www/isdocpal/vendor/yiisoft/yii2/base/Component.php – yii\BaseYii::createObject(['class' => 'yii\filters\AccessControl', 'rules' => [['actions' => ['login', 'error', 'signup', 'request-password-reset'], 'allow' => true], ['actions' => ['logout', 'index'], 'allow' => true, 'roles' => ['@']]]]) at line 663
19. in /var/www/isdocpal/vendor/yiisoft/yii2/base/Component.php – yii\base\Component::attachBehaviorInternal('access', ['class' => 'yii\filters\AccessControl', 'rules' => [['actions' => ['login', 'error', 'signup', 'request-password-reset'], 'allow' => true], ['actions' => ['logout', 'index'], 'allow' => true, 'roles' => ['@']]]]) at line 647
20. in /var/www/isdocpal/vendor/yiisoft/yii2/base/Component.php – yii\base\Component::ensureBehaviors() at line 529
21. in /var/www/isdocpal/vendor/yiisoft/yii2/base/Controller.php – yii\base\Component::trigger('beforeAction', yii\base\ActionEvent) at line 263
22. in /var/www/isdocpal/vendor/yiisoft/yii2/web/Controller.php – yii\base\Controller::beforeAction(yii\base\InlineAction) at line 108
23. in /var/www/isdocpal/common/components/Controller.php – yii\web\Controller::beforeAction(yii\base\InlineAction) at line 32
26272829303132333435363738 if( Yii::$app->getRequest()->isAjax ){
App::setResponseHeader('Content-type', 'application/json');
// header("Content-Type: application/json");
$this->layout = 'blank';
Yii::$app->params["ajaxResponse"] = new AjaxResponse();
}
return parent::beforeAction($action);
}
public function afterAction($action, $result) {
// default ajax response -- INIT
if( Yii::$app->getRequest()->isAjax ){
24. in /var/www/isdocpal/vendor/yiisoft/yii2/base/Controller.php – common\components\Controller::beforeAction(yii\base\InlineAction) at line 149
25. in /var/www/isdocpal/vendor/yiisoft/yii2/base/Module.php – yii\base\Controller::runAction('signup', []) at line 455
26. in /var/www/isdocpal/vendor/yiisoft/yii2/web/Application.php – yii\base\Module::runAction('site/signup', []) at line 84
27. in /var/www/isdocpal/vendor/yiisoft/yii2/base/Application.php – yii\web\Application::handleRequest(yii\web\Request) at line 375
28. in /var/www/isdocpal/backend/web/index.php – yii\base\Application::run() at line 18
12131415161718 require(__DIR__ . '/../../common/config/main-local.php'),
require(__DIR__ . '/../config/main.php'),
require(__DIR__ . '/../config/main-local.php')
);
$application = new yii\web\Application($config);
$application->run();
$_SERVER = [
'REDIRECT_APP_ENV' => 'prod',
'REDIRECT_STATUS' => '200',
'APP_ENV' => 'prod',
'HTTP_HOST' => 'admin.isdocpal.bpmxperts.tk',
'HTTP_CONNECTION' => 'keep-alive',
'HTTP_CACHE_CONTROL' => 'max-age=0',
'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36',
'HTTP_ACCEPT_ENCODING' => 'gzip, deflate, sdch',
'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.8,pt-PT;q=0.6,pt;q=0.4',
'HTTP_COOKIE' => '_ga=GA1.2.78128990.1435876951; _csrf=66282df6eacab21fe5a8eb52671632ff480f173ee5f49fba702541c419e54b5aa%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22_csrf%22%3Bi%3A1%3Bs%3A32%3A%22_-GyIE37cbiK9kBUuU86g75VQdxThxt-%22%3B%7D; PHPSESSID=cqstjm46cpvh1ca3scnjdj2if1',
'PATH' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
'SERVER_SIGNATURE' => '
Apache/2.4.7 (Ubuntu) Server at admin.isdocpal.bpmxperts.tk Port 80
',
'SERVER_SOFTWARE' => 'Apache/2.4.7 (Ubuntu)',
'SERVER_NAME' => 'admin.isdocpal.bpmxperts.tk',
'SERVER_ADDR' => '89.22.97.6',
'SERVER_PORT' => '80',
'REMOTE_ADDR' => '213.30.6.150',
'DOCUMENT_ROOT' => '/var/www/isdocpal/backend/web',
'REQUEST_SCHEME' => 'http',
'CONTEXT_PREFIX' => '',
'CONTEXT_DOCUMENT_ROOT' => '/var/www/isdocpal/backend/web',
'SERVER_ADMIN' => 'danielmeneses.pt@gmail.com',
'SCRIPT_FILENAME' => '/var/www/isdocpal/backend/web/index.php',
'REMOTE_PORT' => '63906',
'REDIRECT_URL' => '/site/signup',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'REQUEST_METHOD' => 'GET',
'QUERY_STRING' => '',
'REQUEST_URI' => '/site/signup',
'SCRIPT_NAME' => '/index.php',
'PHP_SELF' => '/index.php',
'REQUEST_TIME_FLOAT' => 1435931064.0469999,
'REQUEST_TIME' => 1435931064,
];
$_COOKIE = [
'_ga' => 'GA1.2.78128990.1435876951',
'_csrf' => '66282df6eacab21fe5a8eb52671632ff480f173ee5f49fba702541c419e54b5aa:2:{i:0;s:5:"_csrf";i:1;s:32:"_-GyIE37cbiK9kBUuU86g75VQdxThxt-";}',
'PHPSESSID' => 'cqstjm46cpvh1ca3scnjdj2if1',
];
Yii Framework
2015-07-03, 13:44:24
Apache/2.4.7 (Ubuntu)
Yii Framework/2.0.4
user
component class is not your User
model. It's this: https://github.com/yiisoft/yii2/blob/master/framework/web/User.php
Got it! thanks.
Hi,
so, i'm having an issue that i don't really know how to handle. I don't know if is my problem or is a yii2 framework bug. I'm trying running this command:
and i get the error: Error: The configuration for the "user" component must contain a "class" element. And sure enough, i do have a component 'user' and is missing the class. Then i add add the class element and results in:
When i run the command again the migration is applied with no problems. Then comes the problem, i try to open any page on the backend app and i get an error saying that config is trying to set an element that is not valid.. so get confused here. Is there something that i'm missing here?
Of course if i remove 'class' => 'common\models\User' from 'user' component config the app will work, but this is a bit of a pain!
thanks in advance!