schmunk42 / yii2-giiant

Yii 2 Framework Code Generator Gii on Steroids
271 stars 120 forks source link

Uncaught yii\console\Exception: Unknown option: --timestampBehaviorClass #262

Closed kbudylov closed 5 months ago

kbudylov commented 4 years ago

Getting an error while running php ./yii batch:

root@3c8eeb84b6cc:/data/www/back# php ./yii batch --tables=test_table
Running full giiant batch...
PHP Fatal error:  Uncaught yii\console\Exception: Unknown option: --timestampBehaviorClass in /data/www/back/vendor/yiisoft/yii2/console/Controller.php:126
Stack trace:
#0 /data/www/back/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('giiant-model', Array)
#1 /data/www/back/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('gii/giiant-mode...', Array)
#2 /data/www/back/vendor/schmunk42/yii2-giiant/src/commands/BatchController.php(427): yii\console\Application->runAction('gii/giiant-mode...', Array)
#3 /data/www/back/vendor/schmunk42/yii2-giiant/src/commands/BatchController.php(372): schmunk42\giiant\commands\BatchController->actionModels()
#4 [internal function]: schmunk42\giiant\commands\BatchController->actionIndex()
#5 /data/www/back/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#6 /data/www/back/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#7 /data/www/back/vendor/yiisoft/yii2/console/Con in /data/www/back/vendor/yiisoft/yii2/console/Controller.php on line 126

Fatal error: Uncaught yii\console\Exception: Unknown option: --timestampBehaviorClass in /data/www/back/vendor/yiisoft/yii2/console/Controller.php:126
Stack trace:
#0 /data/www/back/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('giiant-model', Array)
#1 /data/www/back/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('gii/giiant-mode...', Array)
#2 /data/www/back/vendor/schmunk42/yii2-giiant/src/commands/BatchController.php(427): yii\console\Application->runAction('gii/giiant-mode...', Array)
#3 /data/www/back/vendor/schmunk42/yii2-giiant/src/commands/BatchController.php(372): schmunk42\giiant\commands\BatchController->actionModels()
#4 [internal function]: schmunk42\giiant\commands\BatchController->actionIndex()
#5 /data/www/back/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#6 /data/www/back/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#7 /data/www/back/vendor/yiisoft/yii2/console/Con in /data/www/back/vendor/yiisoft/yii2/console/Controller.php on line 126

the batch command has the following configuration:

'class' => schmunk42\giiant\commands\BatchController::class,
'overwrite' => true,
'modelBaseClass' => \app\modules\crud\BaseModel::class,
'modelDb' => 'db',
'modelNamespace' => $crudNs . '\models',
'modelQueryNamespace' => $crudNs . '\models\query',
'modelGenerateLabelsFromComments' => true,
'createdAtColumn' => 'created',
'updatedAtColumn' => 'updated',
'extendedModels' => true,
'crudControllerNamespace' => $crudNs . '\controllers',
'crudSearchModelNamespace' => $crudNs . '\models\search',
'crudPathPrefix' => '/crud/',
'crudTidyOutput' => false,
'crudProviders' => [
    \schmunk42\giiant\generators\crud\providers\core\OptsProvider::class,
],

PHP: 7.1.26 Yii version: 2.0.13.3 yii2-giiant version: 0.11.2

This was happened right after upgrade from: Yii: 2.0.13.1 yii2-giiant 0.10.8

[edit schmunk: fixed formatting]

schmunk42 commented 4 years ago

Could you double check the installed versions, actually the option in question was added in 0.11.1, see https://github.com/schmunk42/yii2-giiant/commit/3f7ba0b135eaa8a782bf8154e8c9960c598acc54

kbudylov commented 4 years ago

Could you double check the installed versions, actually the option in question was added in 0.11.1, see 3f7ba0b

yes, after we has downgrade yii-giiant to 0.11.0, the problem has been solved. but, maybe, the proper yii version should be added as dependency, because 0.11.1 is not working with yii 2.0.13.3

schmunk42 commented 4 years ago

Is the above error caused by Yii 2.0.13.3?

kbudylov commented 4 years ago

Is the above error caused by Yii 2.0.13.3?

We did check only with 2.0.13.3, and get this error, but in the same time we has upgraded yii2-giiant from 0.10.8 to 0.11.2 We did not check 0.11.2 with the other versions of Yii, just has downgraded yii-giant to 0.11.0 wich works fine with yii 2.0.13.3

the exception itself caused by Yii:

`PHP Fatal error: Uncaught yii\console\Exception: Unknown option: --timestampBehaviorClass in /data/www/back/vendor/yiisoft/yii2/console/Controller.php:126 Stack trace:

0 /data/www/back/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('giiant-model', Array)

1 /data/www/back/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('gii/giiant-mode...', Array)

2 /data/www/back/vendor/schmunk42/yii2-giiant/src/commands/BatchController.php(427): yii\console\Application->runAction('gii/giiant-mode...', Array)

3 /data/www/back/vendor/schmunk42/yii2-giiant/src/commands/BatchController.php(372): schmunk42\giiant\commands\BatchController->actionModels()

4 [internal function]: schmunk42\giiant\commands\BatchController->actionIndex()

5 /data/www/back/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)

6 /data/www/back/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)

7 /data/www/back/vendor/yiisoft/yii2/console/Con in /data/www/back/vendor/yiisoft/yii2/console/Controller.php on line 126

`

SilverPreece commented 4 years ago

I had a similar issue to this and it was down to the Gii generator not being registered (as shown below). This is documented, but off in a separate Markdown file and not as part of the setup instructions in the main README file. (Also the other Markdown doc in question is a little out of date.) Without this configuration in place, none of the batch commands in 0.12.0 would work for me. Giiant tries to call the code generator with its large set of parameters, but gets the regular Gii generator instead, which causes generation to immediately fail.

The error I saw:

Error: Unknown option: --useTimestampBehavior. Options available: --color, --interactive, --help, --overwrite

What fixed it:

    'modules' => [
        'gii' => [
            'class' => 'yii\gii\Module',
            'generators' => [
                'giiant-model' => [
                    'class'     => 'schmunk42\giiant\generators\model\Generator',
                ]
            ],            
        ],
    ],    

IMO the main README file should be updated to feature this configuration, as it's pretty critical to the extension operating correctly.

Incidentally, great extension. The base/expanded model structure is perfect.

schmunk42 commented 4 years ago

IMO the main README file should be updated to feature this configuration, as it's pretty critical to the extension operating correctly.

A PR would be great.

SilverPreece commented 4 years ago

A PR would be great.

Right you are :-) #272

eluhr commented 5 months ago

closing due to closed issue