Why can't use Imagick extension directly in yii2?

It’s probably a newbie question. But after developing several projects in YII2 he had never had a need to use Imagick directly.

So I installed Imagick the latest version in my local environment (Wamp) and for testing I made a simple file.

$imagen = new Imagick($_SERVER['DOCUMENT_ROOT'] . '/prueba_imagick/ejemplo.png');


$orientation = $imagen->getImageOrientation();
switch ($orientation) {
    case 8:
        $imagen->rotateimage("#000", -90);
    case 3:
        $imagen->rotateimage("#000", 180);
    case 6:
        $imagen->rotateimage("#000", 90);

$imagen->writeImages($_SERVER['DOCUMENT_ROOT'] . '/prueba_imagick/imagen4.png', true);

Then I tried to replicate the same in my yii2 project, advanced template and I get the following error.

## Class 'common\components\Imagick' not found

Please see my screenshot

Thank you very much for your help

Try global namespace.

Your namespace for the Imagick is probably wrong. This is simply just an error with loading the file based on the namespace. It has nothing to do with the Imagick itself.

See Key Concepts: Class Autoloading | The Definitive Guide to Yii 2.0 | Yii PHP Framework