appitudeio / lcms-storage
Official PHP SDK for LCMS Storage - Asset management and CDN platform
Installs: 4
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/appitudeio/lcms-storage
Requires
- php: >=8.1
- guzzlehttp/guzzle: ^7.0
This package is not auto-updated.
Last update: 2025-11-14 12:27:58 UTC
README
Official PHP SDK for LCMS Storage - Asset management and CDN platform.
Features
- Upload files to LCMS Storage with automatic S3 integration
- Delete assets from storage
- List directory contents
- Generate asset URLs with automatic CDN delivery
- Transform images on-the-fly with URL parameters (resize, format conversion)
- Type-safe with PHP 8.1+ features
- Minimal dependencies (Guzzle HTTP client only)
Requirements
- PHP 8.1 or higher
- Composer
Installation
composer require appitudeio/lcms-storage
Quick Start
<?php require_once 'vendor/autoload.php'; use LCMS\Storage\Storage; // Initialize client $storage = new Storage('your-domain.com', 'your_api_key'); // Upload a file $response = $storage->upload('/path/to/local/image.jpg', '/uploads/image.jpg'); echo "Uploaded to: " . $response->url['asset']; // List directory contents $listing = $storage->list('/uploads'); foreach ($listing->items as $item) { echo $item['key'] . " - " . $item['url'] . "\n"; } // Delete file $storage->delete('/uploads/old-image.jpg');
API Reference
Constructor
$storage = new LCMS\Storage\Storage(string $domain, string $apiKey);
Initialize the LCMS Storage client with your domain and API key.
upload()
upload(string $filePath, string $remotePath): UploadResponse
Upload a file to LCMS Storage.
Example:
$response = $storage->upload('/tmp/photo.jpg', '/gallery/photo.jpg'); if ($response->success) { echo "Uploaded: " . $response->url['asset']; }
delete()
delete(string $path): void
Delete a file from LCMS Storage.
Example:
$storage->delete('/gallery/old-photo.jpg');
list()
list(string $path = ''): ListResponse
List contents of a directory.
Example:
$listing = $storage->list('/gallery'); foreach ($listing->items as $item) { echo $item['key'] . " - " . $item['size'] . " bytes\n"; } foreach ($listing->prefixes as $prefix) { echo "Subdirectory: " . $prefix . "\n"; }
Response Objects
UploadResponse
Properties:
bool $success- Whether upload was successfulstring $message- Success or error messagearray $url- Contains 'asset' and 'upload' URLs
Methods:
toArray(): arraytoJson(int $options = 0): string
ListResponse
Properties:
bool $success- Whether the operation was successfulstring $message- Success or error messagestring $path- Directory path that was listedstring $assetBaseUrl- Base URL for accessing assetsarray $items- Array of file items with 'key', 'size', 'url', etc.array $prefixes- Array of subdirectory prefixes
Methods:
count(): int- Number of itemsisEmpty(): bool- Whether directory is emptytoArray(): arraytoJson(int $options = 0): string
Error Handling
try { $response = $storage->upload('/path/to/file.jpg', '/uploads/file.jpg'); if ($response->success) { echo "Success: " . $response->url['asset']; } else { echo "Upload failed: " . $response->message; } } catch (\InvalidArgumentException $e) { echo "Validation error: " . $e->getMessage(); } catch (\RuntimeException $e) { echo "Upload failed: " . $e->getMessage(); }
License
MIT License - see LICENSE file for details.
Support
For issues and questions:
- GitHub Issues: lcms-storage-php/issues
- Email: support@appitudeio.com