Install the CLI Tool Ensure you have the Shopper CLI installed in your Laravel project:
composer require shopperlabs/shopper
Install a Starter Kit Use the provided command to scaffold a kit (e.g., Livewire storefront):
php artisan shopper:kit:install shopperlabs/livewire-starter-kit
resources/views/storefront/, app/Http/Controllers/Storefront/).Verify Installation Check for:
routes/web.php (e.g., /storefront, /checkout).composer.json with new dependencies.First Use Case: Product Page
After installation, test the scaffolded product page (e.g., /products/{slug}). Modify the Livewire component (resources/views/storefront/products/show.blade.php) to customize product display logic.
Extending Scaffolded Features
ProductCard, CartDropdown). Extend them by:
app/Http/Livewire/CustomProductCard.php).mount(), render(), or updatedProperty().// app/Http/Livewire/CustomProductCard.php
namespace App\Http\Livewire;
use Shopper\Livewire\ProductCard as BaseProductCard;
class CustomProductCard extends BaseProductCard {
public function updatedQuantity() {
// Custom logic (e.g., validate stock)
$this->validate(['quantity' => 'max:'.$this->product->stock]);
}
}
resources/views (e.g., resources/views/storefront/layouts/app.blade.php will override the kit’s version).Integration with Shopper Core
Product model tied to Shopper’s Eloquent models. Extend it:
// app/Models/Product.php
use Shopper\Models\Product as BaseProduct;
class Product extends BaseProduct {
protected $appends = ['formattedPrice', 'discountedPrice'];
public function getFormattedPriceAttribute() {
return '$'.$this->price->value;
}
}
Checkout facade to integrate payment logic:
use Shopper\Facades\Checkout;
Checkout::createOrder($cartId, $paymentMethod);
Customizing Routes
routes/web.php. Extend or override them by:
php artisan vendor:publish --tag=shopper-livewire-routes
routes/shopper.php).Asset Management
resources/js/app.js or resources/css/app.css.php artisan shopper:kit:debug to list installed kits and their files.composer update shopperlabs/livewire-starter-kit to pull latest changes (merge conflicts may occur).shopper-kit.yaml.File Overwrite Risks
shopper:kit:install again on an existing kit will overwrite files. To avoid this:
--force carefully: php artisan shopper:kit:install --force.routes/web.php, app/Http/Controllers/).shopper-kit.yaml to exclude files you’ve customized.Dependency Conflicts
replace in composer.json or pin versions in the kit’s shopper-kit.yaml:
dependencies:
livewire/livewire: "^3.0"
Route/Namespace Collisions
/admin vs. /storefront/admin).shopper-kit.yaml or override them in your routes/web.php.Livewire Component Isolation
Database Migrations
products, orders). Running them twice can cause errors.database/migrations/ for duplicate timestamps and rename conflicts.shopper-kit.yaml for invalid paths or commands. Validate with:
php artisan shopper:kit:validate shopperlabs/livewire-starter-kit
livewire:log to trace component interactions:
php artisan livewire:log
config/shopper.php). Override them in config/shopper.php:
'livewire' => [
'enabled' => env('SHOPPER_LIVEWIRE_ENABLED', true),
],
Custom Kit Development
shopper-kit.yaml manifest to your package:
name: "my-custom-kit"
description: "My scaffold for Shopper"
files:
- from: "src/views"
to: "resources/views/storefront"
dependencies:
- "spatie/laravel-permission"
commands:
- "php artisan vendor:publish --tag=permissions"
Hooks and Events
Shopper\Events\KitInstalled). Listen to them in EventServiceProvider:
protected $listen = [
'Shopper\Events\KitInstalled' => [
'App\Listeners\LogKitInstallation',
],
];
Dynamic Kit Installation
ShopperKit facade:
use Shopper\Facades\ShopperKit;
ShopperKit::install('shopperlabs/livewire-starter-kit');
How can I help you explore Laravel packages today?