dimis283
(Dimis283)
1
I am trying to use this simple class (from the source code) http://www.peachpit.com/articles/article.aspx?p=1962481
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();
$cart->isEmpty();
patrickm
(Yiiframework)
2
dimis283
(Dimis283)
3
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
?
dimis283
(Dimis283)
4
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