2017-02-06 4 views
1

私はyii2コン​​ソールコマンドを実行する一方で、その後、私は実行して、それをテストし、この./yii私は./yiiを実行すると、私はこの回答を得た未知のプロパティを取得する:Yiiのコンソールアプリケーション::セッションを実行./yii

ここで
Exception 'yii\base\UnknownPropertyException' with message 'Getting unknown property: yii\console\Application::session' 

in /var/www/html/myweb/vendor/yiisoft/yii2/base/Component.php:143 

Stack trace: 
#0 /var/www/html/myweb/vendor/yiisoft/yii2/di/ServiceLocator.php(73): yii\base\Component->__get('session') 
#1 /var/www/html/myweb/vendor/kartik-v/yii2-grid/Module.php(62): yii\di\ServiceLocator->__get('session') 

は、ここに私のcommon/config/params-local.php

return [ 
     'uploadPath' => __DIR__ .'/../../uploads/', 
     'baseurl' => 'http://localhost/myweb/' 
]; 

されていますここに私のcommon\config\params.php

<?php 
return [ 
    'adminEmail' => '[email protected]', 
    'supportEmail' => '[email protected]', 
    'user.passwordResetTokenExpire' => 3600, 
]; 

は、ここに私のconsole\config\params-local.php

<?php 
return [ 
]; 

であるここに私のconsole\config\params.php

<?php 
return [ 
    'adminEmail' => '[email protected]', 
]; 

である私のcommon\config\main.php

<?php 
return [ 
    'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', 
    'components' => [ 
     'cache' => [ 
      'class' => 'yii\caching\FileCache', 
     ],  
    ], 
    'modules' => [ 
      'redactor' => [ 
        'class' => 'yii\redactor\RedactorModule', 
        'uploadDir' => __DIR__ .'/../../uploads/konten', 
        'uploadUrl' => '/myweb/uploads/konten', 
        'imageAllowExtensions'=>['jpg','png','gif'] 
      ], 

      'gridview' => [ 
        'class' => '\kartik\grid\Module', 
      ] 

    ], 
]; 
01ですここは私 common\config\main-local.php

<?php 
return [ 
    'language' => 'en-US', 
    'sourceLanguage' => 'id-ID', 
    'components' => [ 
      'authClientCollection' => [ 
        'class' => 'yii\authclient\Collection', 
        'clients' => [ 
          'google' => [ 
            'class' => 'yii\authclient\clients\Google', 
            'clientId'  => 'xxxxx-cppd86jm9qfrt77pc684pau01nilf261.apps.googleusercontent.com', 
          ], 
          'facebook' => [ 
            'class' => 'yii\authclient\clients\Facebook', 
            'authUrl' => 'https://www.facebook.com/dialog/oauth?display=popup', 
            'clientId'=> 'xxxxxx16917400', 
            'clientSecret' => 'xxxxxx8d99ff80ce1f713424', 
          ], 
        ], 
      ], 

     'db' => [ 
       'class' => 'yii\db\Connection', 
       'dsn' => 'pgsql:host=192.168.0.106;dbname=mydb', 
       'username' => 'dev', 
       'password' => 'dev123', 
       'charset' => 'utf8', 
       'enableSchemaCache' => false, 
       'schemaMap' => [ 
        'pgsql'=> [ 
        'class'=>'yii\db\pgsql\Schema', 
        'defaultSchema' => 'public2' //specify your schema here 
        ] 
       ], // PostgreSQL 
     ], 

     'mailer' => [ 
      'class' => 'yii\swiftmailer\Mailer', 
      'viewPath' => '@common/mail', 
      // 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, 
     ], 

     'mail' => [ 
      'class' => 'yii\swiftmailer\Mailer', 
      'viewPath' => '@backend/mail', 
      'useFileTransport' => false,//set this property to false to send mails to real email addresses 
      //comment the following array to send mail using php's mail function 

      'transport' => [ 
        'class' => 'Swift_SmtpTransport', 
        'host' => 'iix70.hosting.com', 
        'username' => 'myuser', 
        'password' => 'mypass', 
        'port' => '465', 
        'encryption' => 'ssl', 
      ], 
     ], 
     'i18n' => [ 
     'translations' => [ 
      'app*' => [ 
       'class' => 'yii\i18n\PhpMessageSource', 
       'basePath' => '../../messages', 
       'sourceLanguage' => 'id-ID', 
       'fileMap' => [ 
        'app' => 'app.php', 
       ], 
      ], 


     ], 
    ], 
    ] 
]; 

である私のスクリプトに何かのように見えます。 現在私はubuntuを使っています。

これを修正するにはどうすればよいですか?ですので、エラーではなくyiiコマンドリストで応答する必要があります。

これらのエラーはどのような原因ですか?

ありがとうございます。

+0

'params-local.php'を含めてください。 – topher

+0

コンソールアプリケーションには、私が信じるセッションがありません。セッションにはクッキーが含まれているため、コンソールアプリケーションがそれを処理できるとは思いません。 –

+0

@topherどのファイルに 'params-local.php'を含めるべきですか? @MihaiP。どのようにこれらのエラーを修正するには? ありがとうございます。 –

答えて

4

あなたはcommon/configフォルダファイル、backendなどのすべてのアプリケーションで使用される構成、frontendconsoleapiと他の人に価値を追加します。したがって、高度なテンプレートでは、これらすべてのアプリケーションに関連する値を追加するだけです。 documentationcommonフォルダには、すべてのアプリケーション共通のファイルがあります。この絵は明らかにそれを示しています。あなたの問題のために

enter image description here

は、他の人が述べたように、あなたはコンソール内の任意のsessionを持っていませんが、追加またはこの回答の導入にcommon/config/params-local.phpにこのモジュールを使用し、ベースと、それはconsole/config/params-local.phpで使用され、エラーが発生します:)。

更新:更新した質問に基づいて、あなたのcommon/config/main.phpファイルは次のとおりです。

<?php 
return [ 
    'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', 
    'components' => [ 
     'cache' => [ 
      'class' => 'yii\caching\FileCache', 
     ],  
    ], 
    'modules' => [ 
      'redactor' => [ 
        'class' => 'yii\redactor\RedactorModule', 
        'uploadDir' => __DIR__ .'/../../uploads/konten', 
        'uploadUrl' => '/myweb/uploads/konten', 
        'imageAllowExtensions'=>['jpg','png','gif'] 
      ], 

      'gridview' => [ 
        'class' => '\kartik\grid\Module', 
      ] 

    ], 
]; 

gridviwモジュール、暗黙的にソートの状態を保存するためのsessionを使用しています。反対側ではconfigフォルダにcommonというフォルダを追加しました。前の注記に基づいて、consoleアプリケーションでも使用されます。コンソールにはsessionがありません(あなたのコンソールにグリッドビューは必要ありません:D)、エラーが発生します。この問題を解決するために、(自分の状況や使用に基づいて)frontendmain.phpまたはbackendフォルダにこのライン

'modules' => [ 
       'redactor' => [ 
         'class' => 'yii\redactor\RedactorModule', 
         'uploadDir' => __DIR__ .'/../../uploads/konten', 
         'uploadUrl' => '/myweb/uploads/konten', 
         'imageAllowExtensions'=>['jpg','png','gif'] 
       ], 

       'gridview' => [ 
         'class' => '\kartik\grid\Module', 
       ] 

     ], 

を移動します。

+0

私はまだそれを修正する方法を理解できませんでしたので、私の質問を 'params-local.php'と' params.php'のコードで更新します。 –

+0

@DarkCyber​​だから、問題はあなたの 'common/config/main.php'または 'common/config/main-local.php'を入力します。あなたの質問にそれらを添付できますか?このファイルの 'modules'セクションに' yii2-grid'モジュールを追加してください。 – meysam

+0

が更新されました。あなたが助けてくれることを願っています。 –

関連する問題