kartik-v / yii2-export

A library to export server/db data in various formats (e.g. excel, html, pdf, csv etc.)
http://demos.krajee.com/export
Other
165 stars 126 forks source link

Something wrong happen with non-pure installation: Setting unknown property: kartik\export\ExportMenu::_msgCat #253

Closed bscheshirwork closed 6 years ago

bscheshirwork commented 6 years ago

Prerequisites

Steps to reproduce the issue

  1. php composer require kartik-v/yii2-export "@dev"
  2. add

        $gridColumns = [
            ['class' => 'yii\grid\SerialColumn'],
            'id',
            'name',
            ['class' => 'yii\grid\ActionColumn'],
        ];
    
        // Renders a export dropdown menu
        echo \kartik\export\ExportMenu::widget([
            'dataProvider' => $dataProvider,
            'columns' => $gridColumns
        ]);
    
        // You can choose to render your own GridView separately
        echo \kartik\grid\GridView::widget([
            'dataProvider' => $dataProvider,
            'filterModel' => $searchModel,
            'columns' => $gridColumns
        ]);
  3. 
    Setting unknown property: kartik\export\ExportMenu::_msgCat
    
    /**
     * @inheritdoc
     */
    public function init()
    {
        $this->_msgCat = 'kvexport';
        if (empty($this->options['id'])) {
            $this->options['id'] = $this->getId();
        }
        if (empty($this->exportRequestParam)) {
            $this->exportRequestParam = 'exportFull_' . $this->options['id'];
        }


## Expected behavior and actual behavior

When I follow those steps, I see...

https://github.com/kartik-v/yii2-export/blame/master/ExportMenu.php#L684

from last commit

## Environment

#### Browsers

- [x] Google Chrome
- [ ] Mozilla Firefox
- [ ] Internet Explorer
- [ ] Safari

#### Operating System

- [ ] Windows
- [ ] Mac OS X
- [x] Linux
- [ ] Mobile

#### Libraries

- jQuery version:
- yii2-export version:

## Isolating the problem

- [ ] This bug happens [on the demos page](https://demos.krajee.com/export-demo)
- [ ] The bug happens consistently across all tested browsers
- [ ] This bug happens when using yii2-export without other plugins.
kartik-v commented 6 years ago

Update your packages via composer to get latest dependent extensions.

prabowomurti commented 6 years ago

I have the same issue : https://github.com/kartik-v/yii2-export/commit/cfe22109aa6e45d568891aa0b47bb6fdc16fa786#commitcomment-30438690

kartik-v commented 6 years ago

Folks this is purely a problem of invalid / outdated versions of extensions and their dependencies on your application environment. So you need to fix your composer version dependencies and run composer update to ensure you have the updated/right version.

Basically CROSS CHECK YOUR INSTALLED EXTENSION VERSION WITH THE VERSION ON THIS GITHUB REPO including all dependencies i.e. yii2-export, yii2-krajee-base, yii2-grid etc.

bscheshirwork commented 6 years ago

@kartik-v If run only

$ php composer.phar require kartik-v/yii2-export "@dev"

the dependences of

    "require": {
        "kartik-v/yii2-dynagrid": ">=1.4.5",
        "kartik-v/yii2-dialog": "~1.0",
        "kartik-v/yii2-mpdf": "~1.0",
        "phpoffice/phpspreadsheet": "~1.0"
    },

will not resolved correctly (if we have stable version of your common package?)

@prabowomurti @hanprat run

composer update

to resolve this problem

prabowomurti commented 6 years ago

I am confused. I don't think that running the composer update is the best way to solve the issue, since we have commit the composer.lock file to git and wants every machine uses the exact same of environment (https://stackoverflow.com/questions/12896780/should-composer-lock-be-committed-to-version-control#comment31082402_12896850). What is your other suggestion?

We just installed other package with composer require other/package and the issue shows up. How is it possible? Thank you for the explanation.

kartik-v commented 6 years ago

If you are manually managing extension versions and locking them - you need to cross check what versions of extensions you have set and ensure that you have the dependencies to these extensions of the right versions.

For example, yii2-export latest version requires the latest updated version of dependencies like yii2-grid and yii2-krajee-base to be also installed and updated. If you are not updating those to the latest as well you would have issues/errors like mentioned. Running a composer update ensures these checks are done automatically.

bscheshirwork commented 6 years ago

@prabowomurti

since we have commit the composer.lock file to git and wants every machine uses the exact same of environment

So, we already have a new composer.lock after install new package.

Of course we can update only yii2-grid and yii2-krajee-base like this:

composer update kartik-v/yii2-grid -vvv
composer update kartik-v/yii2-krajee-base -vvv
bscheshirwork commented 6 years ago

What a reason because composer install not update it automatically? I think this happens becouse we can't have a tag of yii2-export and we have unstable @dev

composer require kartik-v/yii2-export "@dev"

I think In next release @kartik-v will change a minor version of each package in chain and composer will work correctly