A
A
Alexander Verbitsky2019-04-20 05:23:29
Yii
Alexander Verbitsky, 2019-04-20 05:23:29

YI2 how to add image via console?

There are no problems with adding pictures through the site, but if through the console, an error occurs:

Yii2 images module not found, may be you didn't add it to your config?

This is when calling the getModule() method
<?php
namespace rico\yii2images;

use yii\base\Exception;

trait ModuleTrait
{
    /**
     * @var null|\rico\yii2images\Module
     */
    private $_module;

    /**
     * @return null|\rico\yii2images\Module
     */
    protected function getModule()
    {
        if ($this->_module == null) {
            $this->_module = \Yii::$app->getModule('yii2images');
        }

        if(!$this->_module){
            throw new Exception("\n\n\n\n\nYii2 images module not found, may be you didn't add it to your config?\n\n\n\n");
        }

        return $this->_module;
    }
}

Maybe not enough information? I just don't understand what the problem is.
for anything that happens in the console:
5cba83a7ceb55616130173.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2019-04-20
@VerbAlexVlad

1. The console application has its own config, you apparently didn’t declare the module in it
2. It’s not a fact that this module is ready to work through the console, but the error is still more likely about point 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question