Installation
composer require shopper/framework
Ensure your Laravel project meets the requirements (PHP 8.1+, Laravel 9+).
Publish Config & Migrations
php artisan vendor:publish --provider="Shopper\Admin\AdminServiceProvider"
php artisan migrate
Basic Configuration
Update .env with:
SHOPPER_ADMIN_ENABLED=true
SHOPPER_ADMIN_URL=/admin
First Use Case
Access /admin to see the default dashboard. Use the built-in CLI to scaffold a product:
php artisan shopper:make:product "My First Product"
Product Management
Product model (Shopper\Admin\Models\Product) for CRUD operations.use Shopper\Admin\Models\Product;
$product = Product::create([
'name' => 'Premium Widget',
'price' => 19.99,
'sku' => 'WIDGET-PRO-001',
]);
Inventory Integration
Inventory trait (Shopper\Admin\Traits\HasInventory) to track stock:
class Product extends Model {
use HasInventory;
}
API-Driven Admin
/admin/api/products) for headless interactions:
$response = Http::get('/admin/api/products');
Event-Driven Extensions
Shopper\Admin\Events\ProductCreated for custom logic:
Event::listen(ProductCreated::class, function ($product) {
// Send notification, update analytics, etc.
});
resources/views/vendor/shopper-admin.Shopper\Admin\Lang\LangManager for multi-language support.Shopper\Admin\Testing\CreatesAdminUser trait in PHPUnit tests.Route Conflicts
SHOPPER_ADMIN_URL doesn’t clash with existing routes. Use php artisan route:list to debug.Middleware Overrides
Shopper\Admin\Http\Middleware\AdminAuth. Avoid overriding it unless necessary.Database Schema Changes
database/migrations/ before running migrate.Caching Quirks
.env:
php artisan config:clear
APP_DEBUG=true) and check storage/logs/laravel.log.Http::debug(true) to inspect API responses.@dump($product) to templates to inspect data.Custom Fields
Product model with custom attributes and add them to the admin panel via:
// In a service provider
Shopper::extend('product', function ($builder) {
$builder->addField('custom_field', 'text');
});
Custom Actions
Shopper\Admin\Contracts\HasActions trait:
class Product extends Model implements HasActions {
public function getActions(): array {
return [
'publish' => function () {
// Custom logic
},
];
}
}
Headless Mode
SHOPPER_ADMIN_UI_ENABLED=false
How can I help you explore Laravel packages today?