Summary
Version 3.0.0 is a major release that introduces a pluggable storage driver system, first-class coupon/tax/shipping objects, a full testing harness, Livewire and Inertia integrations, Artisan generators, and PHPStan static analysis at level 5 with zero errors. Existing code continues to work unchanged - the new features are additive.
Added
- Storage driver system -
CartDriverinterface andCartManagerwith built-inSessionDriver,DatabaseDriver,RedisDriver,NullDriver, andMultiDriverimplementations - @joelwmale Cart::fake()- swaps the active driver for an in-memoryNullDriverand returns aCartFactoryfor fluent test state seeding - @joelwmaleCartFactory- fluent builder for seeding cart state in tests viawithItems(),withCondition(), andwithCoupon()- @joelwmale- Cart assertion methods -
assertContains(),assertCount(),assertTotalQuantity(),assertSubTotal(),assertTotal(),assertConditionApplied(),assertEmpty(),assertNotEmpty()- @joelwmale Couponabstract class - extend to create first-class coupon objects that convert toCartCondition- @joelwmaleTaxRuleabstract class - extend to create first-class tax rules that convert toCartCondition- @joelwmaleShippingRateabstract class - extend to create first-class shipping rates that convert toCartCondition- @joelwmaleCart::coupon(),Cart::tax(),Cart::shipping()- accept first-class objects or rawCartConditioninstances - @joelwmaleHasCarttrait - Livewire-aware trait with reactive$cartItems,$cartTotal,$cartSubTotal,$cartCountproperties and proxy methods - @joelwmaleShareCartWithInertia- static helper for sharing cart state viaHandleInertiaRequests::share()- @joelwmalecart:installArtisan command - publishes config and scaffoldsapp/Cart/directory structure - @joelwmalecart:make:coupon,cart:make:tax,cart:make:shipping,cart:make:driverArtisan commands - generate typed stub classes - @joelwmalecart:debugArtisan command - dumps current cart state (non-production only) - @joelwmaleapplies_tosupport on item conditions - limit a condition to the first N units of a line item - @joelwmale- PHPStan level 5 static analysis with zero errors, run in CI on PHP 8.3 - @joelwmale
- Laravel 13 support - @joelwmale
Changed
Cartconstructor now accepts aCartDriverinstance instead of raw session/database storage; applications using the service container are unaffected - @joelwmale- Config publish tag renamed from
configtocart-configto avoid conflicts with other packages - @joelwmale CartSessionremoved and replaced by the driver system - @joelwmale
Fixed
- Redis driver TTL units corrected from minutes to seconds - @joelwmale
CartFacade@mixinand@methodPHPDoc restored for IDE and PHPStan support - @joelwmale- Missing return type added to
getAssociatedModel- @joelwmale - Null-safe
json_decodeinRedisDriver- @joelwmale - Conditions now serialized to arrays before storage, preventing serialization inconsistencies across drivers - @joelwmale
- Guard against null writes in
SessionDriver::setSessionKey- @joelwmale cart:make:*commands now validate class name input and check for file write failures - @joelwmale