shopping class problem

I am trying to use this simple class (from the source code)

I put the source code at vendors/myclass folder giving the namespace mycart.

But when I am trying to use at controller,I have the error Class

How can I use this class properly?

 $cart=new \mycart\ShoppingCart();


I set

 Yii::$classMap['dimis\mycart\ShoppingCart'] ='@vendor/mycart/ShoppingCart.php';

and it is ok

But now there is the error Interface ‘dimis\mycart\Iterator’ not found

class ShoppingCart     implements Iterator, Countable

I have to delete

implements Iterator, Countable


I am trying to create a alias for these classes,but it is not working.How can I fix it?

The files are in vendor\myclass and they have the namespace dimis\mycart

I have this error The configuration for the "aliases" component must contain a "class" element

'components' => [.....

'aliases' => [

        '@dimis\mycart' => '@vendor/mycart',

       // 'dimis\mycart\Item' => '@vendor/mycart/item.php',


[edit]It seems that I solve it,I put the code outside the ‘components’ area