Building e-commerce applications with Laravel has always required a mix of third-party packages and custom logic. Enter Lunar — an open-source e-commerce package built specifically for Laravel that gives you powerful tools to manage products, carts, customers, and orders while staying flexible and developer-friendly.
In this post, we’ll go through how to integrate Lunar into a fresh Laravel project and explore some of its core features.
1. Install a Fresh Laravel Project
If you don’t have one yet, start by creating a fresh Laravel application:
composer create-project laravel/laravel my-lunar-store
cd my-lunar-store2. Install the Lunar Package
Next, pull in the Lunar package via Composer:
composer require lunarphp/lunarThen, publish the configuration and assets:
php artisan vendor:publish --tag=lunar.config
php artisan vendor:publish --tag=lunar.assetsRun the migrations:
php artisan migrate3. Set Up the Admin Panel
Lunar ships with an admin hub for managing your store. Install it with:
php artisan lunar:installThis will guide you through creating the first admin user.
You can now access the admin panel at:
https://your-app.test/admin4. Defining Products
Products are managed through the Lunar admin panel. You can create collections, attributes, and assign pricing.
But if you prefer code-first setup, you can use factories or seeder classes. Example:
use Lunar\Models\Product;
Product::create([
'status' => 'published',
'attribute_data' => [
'name' => 'Sample Product',
'description' => 'This is a test product.',
],
]);5. Managing a Cart
Lunar provides cart functionality out of the box:
use Lunar\Facades\Cart;
$cart = Cart::create();
$cart->add(
purchasable: $productVariant,
quantity: 2
);
$cart->calculate();You can then display cart totals in your frontend:
Cart Total: {{ $cart->total->formatted() }}6. Orders and Checkout
When a customer is ready to checkout, you can convert a cart into an order:
$order = $cart->createOrder([
'user_id' => auth()->id(),
'status' => 'pending',
]);Conclusion
With Laravel + Lunar, you get a modern e-commerce foundation that’s extensible, integrates seamlessly with Laravel, and gives you full control over your store logic.
If you’re looking for a developer-friendly alternative to rigid SaaS platforms, Lunar is worth exploring for your next e-commerce project.