PHPackages                             mirahost/phpcart - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. mirahost/phpcart

ActiveLibrary[Framework](/categories/framework)

mirahost/phpcart
================

Simple framework agnostic shopping cart

v1.2.0(1y ago)028MITPHPPHP &gt;=5.4.0

Since Apr 22Pushed 1y agoCompare

[ Source](https://github.com/mirahost/phpcart)[ Packagist](https://packagist.org/packages/mirahost/phpcart)[ Docs](https://github.com/mirahost/phpcart)[ RSS](/packages/mirahost-phpcart/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (11)Used By (0)

PHPCart
=======

[](#phpcart)

Simple framework agnostic shopping cart. Forked from anam-hossain/phpcart to continue development.

Features
--------

[](#features)

- Simple API
- Support multiple cart instances
- Framework agnostic

Requirements
------------

[](#requirements)

- PHP 5.4+

Installation
------------

[](#installation)

PHPCart is available via Composer

```
$ composer require anam/phpcart
```

Usage
-----

[](#usage)

### Add Item

[](#add-item)

The add method required `id`, `name`, `price` and `quantity` keys. However, you can pass any data that your application required.

```
use Mirahost\Phpcart\Cart;

$cart = new Cart();

$cart->add([
    'id'       => 1001,
    'name'     => 'Skinny Jeans',
    'quantity' => 1,
    'price'    => 90
]);
```

### Update Item

[](#update-item)

```
$cart->update([
    'id'       => 1001,
    'name'     => 'Hoodie'
]);
```

### Update quantity

[](#update-quantity)

```
$cart->updateQty(1001, 3);
```

### Update price

[](#update-price)

```
$cart->updatePrice(1001, 30);
```

### Remove an Item

[](#remove-an-item)

```
$cart->remove(1001);
```

### Get all Items

[](#get-all-items)

```
$cart->getItems();
// or
$cart->items();
```

### Get an Item

[](#get-an-item)

```
$cart->get(1001);
```

### Determining if an Item exists in the cart

[](#determining-if-an-item-exists-in-the-cart)

```
$cart->has(1001);
```

### Get the total number of items in the cart

[](#get-the-total-number-of-items-in-the-cart)

```
$cart->count();
```

### Get the total quantities of items in the cart

[](#get-the-total-quantities-of-items-in-the-cart)

```
$cart->totalQuantity();
```

### Total sum

[](#total-sum)

```
$cart->getTotal();
```

### Empty the cart

[](#empty-the-cart)

```
$cart->clear();
```

### Multiple carts

[](#multiple-carts)

PHPCart supports multiple cart instances, so that you can have as many shopping cart instances on the same page as you want without any conflicts.

```
$cart = new Cart('cart1');
// or
$cart->setCart('cart2');
$cart->add([
    'id'       => 1001,
    'name'     => 'Skinny Jeans',
    'quantity' => 1,
    'price'    => 90
]);

//or
$cart->named('cart3')->add([
    'id'       => 1001,
    'name'     => 'Jeans',
    'quantity' => 2,
    'price'    => 100
]);
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance42

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 86.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~446 days

Recently: every ~663 days

Total

9

Last Release

477d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7101f20c62d79eaa8bf732ae25a480c5d5957e4f00d5c355953f1e9cfa6f45e5?d=identicon)[mirahost](/maintainers/mirahost)

---

Top Contributors

[![anam-hossain](https://avatars.githubusercontent.com/u/5017268?v=4)](https://github.com/anam-hossain "anam-hossain (53 commits)")[![mirahost](https://avatars.githubusercontent.com/u/150337?v=4)](https://github.com/mirahost "mirahost (7 commits)")[![barmmie](https://avatars.githubusercontent.com/u/5102700?v=4)](https://github.com/barmmie "barmmie (1 commits)")

---

Tags

cartshopping cartLaravel shopping cartLaravel cartphp cart

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mirahost-phpcart/health.svg)

```
[![Health](https://phpackages.com/badges/mirahost-phpcart/health.svg)](https://phpackages.com/packages/mirahost-phpcart)
```

###  Alternatives

[anam/phpcart

Simple framework agnostic shopping cart

12115.4k](/packages/anam-phpcart)[darryldecode/cart

Laravel 5 Shopping cart

1.4k1.7M7](/packages/darryldecode-cart)[lukepolo/laracart

A simple cart for Laravel

583135.4k1](/packages/lukepolo-laracart)[binafy/laravel-cart

Laravel Cart is a customizable package for adding shopping cart functionality to Laravel applications

40445.9k](/packages/binafy-laravel-cart)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
