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.

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

$imagen->thumbnailImage(100,0);

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

$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.
\Imagick

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