Download the PHP package centrex/laravel-cart without Composer

On this page you can find all versions of the php package centrex/laravel-cart. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-cart

Laravel Cart

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A full-featured shopping cart for Laravel. Supports session, cookie, and database storage drivers, multiple named cart instances (e.g. wishlist), Livewire components (CartIcon, CartDrawer), and a REST API — all swappable via a single config key.

Installation

For the database driver, run:

Configuration

Drivers

Driver Persists across requests Auth-aware Best for
session Until session expires No Default, server-rendered apps
cookie 30 days (configurable) No Guest carts, headless/SPA
database Permanently (until cleared) Yes — uses user ID for auth, session ID for guests Authenticated users, cart recovery

Usage

Facade

Reading the cart

CartItem properties

Multiple cart instances

Use instance() to work with independent named carts. Returns a new Cart object — does not mutate the original singleton.

Events

Listen to cart events in your application's EventServiceProvider:

Cookie storage — guest carts

Note: Cookie writes are queued for the HTTP response. A get() call in the same request reads what the browser already sent, not what was queued. This is standard browser behaviour.

Database storage — persistent & auth-aware

To migrate a guest cart to a user after login:


Livewire Components

Requires livewire/livewire ^3.

CartIcon

Displays a shopping bag icon with an item count badge. Updates automatically when the cart changes.

Clicking the icon dispatches the open-cart browser event, which opens CartDrawer.

CartDrawer

A slide-out panel showing the full cart with quantity controls, item removal, and totals.

Open the drawer from any element:

Triggering a cart update from your own Livewire components

After adding an item to the cart in a Livewire component, dispatch cart-updated so CartIcon and CartDrawer refresh automatically:

Publish views for customisation


REST API

All endpoints are prefixed with api (configurable via api_prefix) and use the api middleware (configurable via api_middleware).

Method Endpoint Description
GET /api/cart Get full cart (items, count, subtotal, tax, total)
POST /api/cart/items Add item to cart
PUT /api/cart/items/{rowId} Update item quantity
DELETE /api/cart/items/{rowId} Remove item
DELETE /api/cart Clear cart

GET /api/cart

POST /api/cart/items

PUT /api/cart/items/{rowId}

DELETE /api/cart/items/{rowId}

Returns 204 No Content.

DELETE /api/cart

Returns 204 No Content.


Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-cart with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/cookie Version ^11.0|^12.0|^13.0
illuminate/database Version ^11.0|^12.0|^13.0
illuminate/http Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package centrex/laravel-cart contains the following files

Loading the files please wait ...