laravel-shirtigo / wrapper
Laravel wrapper for the Shirtigo PHP API SDK
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/laravel-shirtigo/wrapper
Requires
- php: ^8.1
- laravel/framework: ^10.0|^11.0
- webkult/shirtigo-php-api-wrapper: ^1.0
Requires (Dev)
- driftingly/rector-laravel: ^0.18
- friendsofphp/php-cs-fixer: ^3.0
- orchestra/testbench: ^8.0|^9.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpunit/phpunit: ^10.0
- rector/rector: ^0.18
This package is auto-updated.
Last update: 2025-10-15 15:02:04 UTC
README
A Laravel wrapper for the Shirtigo PHP API SDK that simplifies the integration of Shirtigo services into Laravel applications.
Installation
composer require laravel-shirtigo/wrapper
Configuration
Publish the configuration file:
php artisan vendor:publish --tag=shirtigo-config
Configure your environment variables in the .env
file:
SHIRTIGO_API_KEY=your_api_key_here SHIRTIGO_BASE_URL=https://cockpit.shirtigo.com/api/ SHIRTIGO_CACHE_ENABLED=true SHIRTIGO_CACHE_TTL=3600 SHIRTIGO_RETRY_ATTEMPTS=3 SHIRTIGO_LOGGING_ENABLED=true
Usage
Using the Facade
use LaravelShirtigo\Facades\Shirtigo; // Get all orders $orders = Shirtigo::orders()->getAll(); // Get single order $order = Shirtigo::orders()->get('ORDER-123'); // Get all products $products = Shirtigo::products()->getAll(); // Create design $design = Shirtigo::designs()->createFromFile('/path/to/design.png');
Service Injection
use LaravelShirtigo\Contracts\ShirtigoServiceInterface; class OrderController extends Controller { public function __construct( private ShirtigoServiceInterface $shirtigo ) {} public function index() { $orders = $this->shirtigo->orders()->getAll(); return view('orders.index', compact('orders')); } }
API Services
Order Service
// Get all orders $orders = Shirtigo::orders()->getAll( page: 1, filter: 1, // Status filter items: 50, search: 'search term' ); // Create order $order = Shirtigo::orders()->create([ 'customer' => [...], 'products' => [...], 'delivery_address' => [...] ]); // Cancel order Shirtigo::orders()->cancel('ORDER-123'); // Retry payment Shirtigo::orders()->retryPayment('ORDER-123');
Product Service
// Get all products $products = Shirtigo::products()->getAll(); // Create product $product = Shirtigo::products()->create([ 'name' => 'T-Shirt', 'description' => 'A cool T-Shirt', 'base_product_id' => 123 ]); // Update product Shirtigo::products()->update(123, [ 'name' => 'Updated Name' ]);
Design Service
// Create design from file $design = Shirtigo::designs()->createFromFile('/path/to/design.png', [ 'name' => 'My Design' ]); // Create design from URL $design = Shirtigo::designs()->createFromUrl('https://example.com/design.png'); // Create design from Base64 $design = Shirtigo::designs()->createFromBase64($base64Data);
Image Service
// Generate mockup images $mockups = Shirtigo::images()->generateMockupImages([ 'product_id' => 123, 'design_id' => 456 ]); // Remove background $result = Shirtigo::images()->removeBackground([ 'image_url' => 'https://example.com/image.png' ]);
Models
The wrapper provides Eloquent-like models for API responses:
use LaravelShirtigo\Models\Order; $order = Order::fromArray($orderData); echo $order->getReference(); echo $order->getTotalPrice(); echo $order->isPaid() ? 'Paid' : 'Not paid'; $products = $order->getProducts(); foreach ($products as $product) { echo $product->getQuantity() . 'x ' . $product->getColor(); }
Artisan Commands
Sync products
php artisan shirtigo:sync-products --limit=100 --force
Sync orders
php artisan shirtigo:sync-orders --status=1 --limit=50 --page=1
Caching
The wrapper supports automatic caching of API responses:
// Caching is enabled by default $products = Shirtigo::products()->getAll(); // Will be cached // Disable cache for specific request $products = Shirtigo::products()->getAll(); // Without cache
Error Handling
use LaravelShirtigo\Exceptions\ShirtigoException; try { $orders = Shirtigo::orders()->getAll(); } catch (ShirtigoException $e) { // Handle API error echo 'Error: ' . $e->getMessage(); echo 'Status Code: ' . $e->getStatusCode(); }
Logging
API calls are automatically logged (when enabled):
// In configuration 'logging' => [ 'enabled' => true, 'channel' => 'default', ],
Testing
composer test
Configuration
The complete configuration can be found in the config/shirtigo.php
file:
return [ 'api_key' => env('SHIRTIGO_API_KEY'), 'base_url' => env('SHIRTIGO_BASE_URL', 'https://cockpit.shirtigo.com/api/'), 'cache' => [ 'enabled' => env('SHIRTIGO_CACHE_ENABLED', true), 'ttl' => env('SHIRTIGO_CACHE_TTL', 3600), 'prefix' => 'shirtigo_', ], 'retry' => [ 'attempts' => env('SHIRTIGO_RETRY_ATTEMPTS', 3), 'delay' => env('SHIRTIGO_RETRY_DELAY', 1000), ], 'timeout' => [ 'connect' => env('SHIRTIGO_CONNECT_TIMEOUT', 30), 'read' => env('SHIRTIGO_READ_TIMEOUT', 60), ], 'logging' => [ 'enabled' => env('SHIRTIGO_LOGGING_ENABLED', true), 'channel' => env('SHIRTIGO_LOG_CHANNEL', 'default'), ], ];
License
GPL-3.0
Author
Benjamin Klein
Email: info@webkult.de
Support
For questions or issues, please create an issue in the GitHub repository.