PHPackages                             rapideinternet/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. rapideinternet/phpcart

ActiveLibrary

rapideinternet/phpcart
======================

Simple framework agnostic shopping cart

125PHP

Since May 30Pushed 2y agoCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

PHPCart
=======

[](#phpcart)

Simple framework agnostic shopping cart.

Features
--------

[](#features)

- Simple API
- Support multiple cart instances
- Framework agnostic, with optional Laravel integration

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

[](#requirements)

- PHP 5.4+

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

[](#installation)

PHPCart is available via Composer

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

Integrations
------------

[](#integrations)

Laravel 4 and Laravel 5 integrations

Although PHPCart is framework agnostic, it does support Laravel out of the box and comes with a Service provider and Facade for easy integration.

After you have installed the PHPCart, open the config/app.php file which is included with Laravel and add the following lines.

In the $providers array add the following service provider.

```
'Anam\Phpcart\CartServiceProvider'
```

Add the facade of this package to the $aliases array.

```
'Cart' => 'Anam\Phpcart\Facades\Cart'
```

You can now use this facade in place of instantiating the Cart yourself in the following examples.

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 Anam\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

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5a784facd31d0bfe768b4919f5fe9c5537729fb36f5579bae95a2ec080f33448?d=identicon)[rapideinternet](/maintainers/rapideinternet)

### Embed Badge

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

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

PHPackages © 2026

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