Lunar PHP Documentation
website·Indexed 32 days ago
https://docs.lunarphp.com/1.x/getting-started/overview/introductionA headless e-commerce package for Laravel providing a comprehensive catalog, cart, and checkout flow. Includes a Filament-based admin panel, support for payment integrations like Stripe, PayPal, and Opayo, and extensible systems for shipping, taxation, and search.
What's inside Lunar
- Lunar is a headless e-commerce package for Laravel that provides the backend logic for online stores (products, carts, orders, payments, discounts, and taxation) while allowing developers complete ownership of the codebase, data, and storefront. Because it is a Laravel package rather than a standalone application, it integrates directly into any Laravel project without requiring external APIs or separate system maintenance.
Overview of Lunar Payment Architecture
Lunar employs a driver-based payment system managed via the
Paymentsfacade. The architecture consists of three layers:- Payment Manager (
Lunar\Facades\Payments): Routes calls to the active driver. - Payment Type (e.g.,
Lunar\Stripe\StripePaymentType): Implements provider-specific logic for authorization, capture, and refunds. - Transactions (
Lunar\Models\Transaction): Persistent records of payment events linked to orders.
- Payment Manager (
Overview of Media Management in Lunar
Lunar uses thelaravel-medialibrarypackage by Spatie to handle media across models. It extends this functionality with configurable media definitions, automatic image conversions, and a primary image management system. Most models support media via theLunar\Base\Traits\HasMediatrait.Overview of StorefrontSession facade
TheStorefrontSessionfacade manages session-bound resources required by a storefront, including the active channel, currency, customer, and customer groups. When the facade is first resolved, it automatically initializes these resources (initChannel(),initCustomerGroups(),initCurrency(), andinitCustomer()) to restore previously set session values or apply defaults.use Lunar\Facades\StorefrontSession;Overview of Lunar SEO URLs
Lunar provides a polymorphic URL system to create SEO-friendly slugs for models (e.g.,/products/apple-iphoneinstead of/products/1). Each URL is associated with a specific language, and each model can have one default URL per language. These are lookup mechanisms for storefront routing and are not Laravel route definitions.Overview of Lunar Search indexing
Lunar uses Laravel Scout to provide a flexible, driver-based search system. While the database driver is available for basic search, advanced engines like Meilisearch and Typesense are supported for features such as faceted filtering and relevance tuning. All search configuration is managed inconfig/lunar/search.php.Overview of Lunar Admin Panel features
Lunar's admin panel is built on Filament and provides a comprehensive interface for managing e-commerce operations. Key management capabilities include:
- Products: Handling variants, pricing, images, and associations.
- Collections: Organizing products into collection groups.
- Orders: Full lifecycle management of customer orders.
- Customers: Managing customer profiles and customer groups.
- Discounts: Creating flexible conditions and rewards.
- Settings: Configuring channels, languages, currencies, taxes, and tags.
Overview of the Inertia + Vue Starter Kit
The Inertia + Vue Starter Kit is a production-ready storefront foundation for LunarPHP. It is built using Laravel, Inertia.js, and Vue 3, allowing developers to create a single-page application (SPA) experience while utilizing Laravel's server-side routing and controllers. Unlike the Livewire Starter Kit, this version provides a fully realized front-end experience designed for production stores.Overview of Lunar 2.0 Alpha features
v2-0-0-alphaLunar 2.0 introduces a significant restructuring of the core and a new admin panel. Key architectural changes include:
- Fulfilments: Orders are now managed via dedicated fulfilment records including methods, carriers, and tracking.
- Inventory: Stock tracking is now per-variant and per-location, supporting movements, reservations, and reconciliation.
- Regions: A new grouping mechanism for channels, currencies, languages, and tax behaviors for specific markets.
- Storefront Context: Pricing and availability are now driven by a single session-backed context.
- Pricing Engine: Implementation of a fluent pricing API and a dedicated
PriceValuetype. - Extension Model: Core logic is moved to the
Lunar\Core\...namespace, utilizing swappable action contracts for model verb methods and container bindings instead of config-based class substitution.
Overview of Lunar Attributes
Attributes allow you to store custom, translatable data against Eloquent models (such as Products, Collections, and Customers). They are organized into Attribute Groups for logical collection and display purposes (e.g., an 'SEO' group containing 'Meta Title' and 'Meta Description').Overview of Lunar Taxation
Lunar provides a configurable manual tax rule system to calculate sales tax on orders. For highly complex taxation scenarios, such as US state taxes, it is recommended to integrate with an external service like TaxJar. Custom tax drivers can be implemented to extend the standard calculation logic.Core features introduced in Lunar v2.0.0
Lunar v2.0.0 serves as the foundational release introducing several breaking changes and new core concepts to improve performance and extensibility:
- Reworked custom attributes
- A dedicated pricing engine with improved price field performance
- Cart performance optimizations
- New core concepts: regions and storefront context
- Core support for fulfilments and per-location inventory
- A cleaner extension model based on native Laravel seams