-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migration error if cookieValidationKey is set in config #1772
Comments
Yes this is bug and maybe also a "design" problem from luya console commands. As we don't want people to copy past two configs just to run console commands, we merge those into one, therefore the cookieValidationKey is only existing in the luya\web\Request component and not luya\console\Request. Not sure how to consistent fix this "splitting" behavior. |
Same example An Error occurred while handling another error:
yii\base\UnknownPropertyException: Setting unknown property: yii\console\Response::formatters in .../vendor/yiisoft/yii2/base/Component.php:209 |
Maybe it is not about duplication, but overriding? Like if I have a problem with migration command when I've tryed to inject menu item via I have this code at bootstrapped module Yii::$app->menu->injectItem($newItem); It works fine for frontend, but when I've try to run migration I've got
Btw basic yii2 template has standalone console config. I think cause it needs different bootstrap section and other modules. https://github.com/yiisoft/yii2-app-basic/blob/master/config/console.php |
hi, @nadar @nick-denry ;
` $config_file = $this->isCli()? require 'env-console.php': require'env-local.php';
return $config_file; 第二种:我希望以Luya的方式修改\luya\base\Boot: /**
* @var string The path to the config file, which returns an array containing you configuration.
*/
public $configFile = '../configs/env.php';
/**
* @var string Maybe it should be modified in Luya's way
*/
public $configFileConsole = '../configs/env-console.php';
/**
* Get the config array from the configFile path with the predefined values.
*
* @throws \luya\Exception Throws exception if the config file does not exists.
* @return array The array which will be injected into the Application Constructor.
*/
public function getConfigArray(){
...
$config_file = $this->isCli()? require $this->configFileConsole: $this->configFile;
...
} |
Therefore it could have names as The idea seems ok to me. Is there a technical reason why console should have the same config? |
This issue is still not resolved and i totally agree with everyone we need a solution for that which must support the handling of console and web application. I have made a pull request proposal, if someone likes to take a view, feel free to comment: |
$config = new Config('myapp', dirname(__DIR__), [
'siteTitle' => 'My LUYA Project',
'defaultRoute' => 'cms',
// other application level configurations
]);
// define global components which works either for console or web runtime
$config->component('mail', [
'host' => 'xyz',
'from' => '[email protected]',
]);
$config->component('db', [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=prod_db',
'username' => 'foo',
'password' => 'bar',
]);
// define components which are only for web or console runtime:
$config->webComponent('request', [
'cookieValidationKey' => 'xyz',
]);
// which is equals to, but the above is better to read and structure in the config file
$config->component('request', [
'cookieValidationKey' => 'xyz',
])->webRuntime();
// adding modules
$config->module('admin', [
'class' => 'luya\admin\Module',
'secureLogin' => true,
]);
$config->module('cms', 'luya\cms\frontend\Module'); // which is equals to $config->module('cms', ['class' => 'luya\cms\frontend\Module']);
// export and generate the config for a given enviroment or environment independent.
return $config->toArray(); // returns the config not taking care of enviroment variables like prod, env
return $config->toArray(Config::ENV_PROD); Switching between envs can be usefull if certain configurations should only apply on a certain environment. Therefore you can add $config->component('db', [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=prod_db',
'username' => 'foo',
'password' => 'bar',
])->env(Config::ENV_LOCAL);
$config->component('db', [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=prod_db',
'username' => 'foo',
'password' => 'bar',
])->env(Config::ENV_DEV);
$config->component('db', [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=prod_db',
'username' => 'foo',
'password' => 'bar',
])->env(Config::ENV_PROD);
return $config->toArray(Config::ENV_PROD); // would only return the prod env db component |
What steps will reproduce the problem?
Set the
cookieValidationKey
parameter in componentrequest
and create or execute migrationWhat is the expected result?
Successful execution of migration
What do you get instead? (A Screenshot can help us a lot!)
yii\base\UnknownPropertyException: Setting unknown property: yii\console\Response::isSent in vendor/yiisoft/yii2/base/Component.php:209
Stack trace:
#0 vendor/yiisoft/yii2/BaseYii.php(546): yii\base\Component->__set('cookieValidatio...', 'me9M5KPGpji_WjU...')
LUYA Check ouput (run this script and post the result: luyacheck.php)
1: [in_array('mod_rewrite', apache_get_modules())] true
2: [ini_get('short_open_tag')] '1'
3: [ini_get('error_reporting')] '22519'
4: [phpversion()] '7.0.10'
5: [php_ini_loaded_file()] '/Applications/AMPPS/php/etc/php.ini'
6: [php_sapi_name()] 'apache2handler'
Additional infos
The text was updated successfully, but these errors were encountered: