Download the PHP package al-mamun-devops/laravel-shopping-cart without Composer
On this page you can find all versions of the php package al-mamun-devops/laravel-shopping-cart. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download al-mamun-devops/laravel-shopping-cart
More information about al-mamun-devops/laravel-shopping-cart
Files in al-mamun-devops/laravel-shopping-cart
Package laravel-shopping-cart
Short Description Lightweight shopping cart for Laravel 12 using session or filesystem (no DB)
License MIT
Informations about the package laravel-shopping-cart
🛒 Laravel Shopping Cart
A lightweight and reusable shopping cart package for Laravel 12+, designed for developers who want to add cart functionality without needing a database. This package uses Session or File Storage for managing cart data.
🚀 Features
- ✅ Works with Laravel 12+
- 🧠 No database required
- 🗃️ Storage options: Session or File system
- 🔧 Simple API for adding, updating, removing, and clearing items
- 💰 Automatic cart total and item count calculation
- 📦 Easy to install and integrate into any Laravel project
📦 Installation
1. Add the package via Composer (local or from GitHub)
2. Publish configuration file
This will publish config/shoppingcart.php where you can choose storage type:
⚙️ Configuration
You can choose between Session and File Storage:
| Option | Description |
|---|---|
session |
Stores cart data in the Laravel session. Default option. |
file |
Persists cart data in a JSON file under storage/app/shopping_cart.json. |
Set your preferred option in the .env file:
🧰 Usage
Use the Cart Facade to manage cart operations:
🧩 Example Controller
🧱 Folder Structure
🧠 Methods Summary
| Method | Description |
|---|---|
add($id, $name, $price, $quantity = 1, $attributes = []) |
Add an item to the cart |
update($id, $quantity) |
Update the quantity of an item |
remove($id) |
Remove an item from the cart |
clear() |
Clear all items from the cart |
all() |
Retrieve all cart items |
total() |
Calculate total price |
count() |
Count total number of items |
🧑💻 Development Setup
If you are developing this package locally within a Laravel app:
- Place the package inside
packages/al-mamun-devops/laravel-shopping-cart -
Add this to your main app’s
composer.json: -
Run:
- Test it in your app!
🪪 License
This package is open-sourced software licensed under the MIT license.
👨💻 Author
Md Al Mamun
GitHub: al-mamun-devops
💡 Contributing
Pull requests are welcome! If you’d like to enhance the package (e.g. add Redis, Cookie storage, or tests), feel free to open an issue or PR.
⭐ Star the Repo
If you find this package helpful, please give it a ⭐ on GitHub to support future development!