Download the PHP package daycode/stup-images without Composer
On this page you can find all versions of the php package daycode/stup-images. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download daycode/stup-images
More information about daycode/stup-images
Files in daycode/stup-images
Package stup-images
Short Description Stup Images or Store Or Update Images is a Package For Storing / Updating the Images, More Clear Codes and Upgrade Readability
License MIT
Informations about the package stup-images
Laravel Stup Image
Stup Image is a powerful Laravel package for storing and updating images with clean, readable code. Integrated with the Intervention Image library, it provides an elegant solution for handling file uploads with advanced features like automatic resizing, configurable filename hashing, and flexible storage options.
✨ Features
- 🚀 Simple and intuitive API for file uploads
- 🖼️ Automatic image resizing on upload
- 🔒 Configurable filename hashing for security
- 📁 Flexible storage disk configuration (local, S3, etc.)
- 🔄 Sync upload (replace old file automatically)
- 📦 Multiple file uploads support
- 🗑️ Easy file deletion
- ⚙️ Customizable configuration
- ✅ File extension validation
📦 Installation
1. Install via Composer
2. Publish Configuration (Optional)
This will create a config/stup-image.php file where you can customize the package behavior.
3. Configure Storage Disk
Make sure your config/filesystems.php has the desired disk configured. By default, the package uses the FILESYSTEM_DISK from your .env file.
4. Link Storage (if using public disk)
5. Clear Cache
⚙️ Configuration
After publishing the config file, you can customize these options in config/stup-image.php:
🚀 Usage
Basic Setup
Add the Stupable trait to your controller or any class:
📤 Upload File
Upload a single file to storage:
🖼️ Upload with Auto Resize
Automatically resize images during upload:
🔄 Sync Upload (Update & Replace)
Upload a new file and automatically delete the old one:
📦 Upload Multiple Files
Upload multiple files at once:
🗑️ Delete File
Delete a file from storage:
📖 API Reference
uploadFile(UploadedFile $file, string $path, ?array $resize = []): string
Upload a single file to storage.
Parameters:
$file- The uploaded file instance$path- Storage path (relative to your configured disk)$resize- Optional. Array with[width, height]for automatic resizing
Returns: Filename (string) or throws UploadException
syncUploadFile(UploadedFile $file, ?string $oldFileName, string $path): string
Upload a new file and delete the old one.
Parameters:
$file- The new uploaded file$oldFileName- The old filename to delete (nullable)$path- Storage path$resize- Optional. Array with[width, height]for automatic resizing
Returns: New filename (string)
uploadMultipleFiles(array $files, string $path): array
Upload multiple files at once.
Parameters:
$files- Array of uploaded files$path- Storage path$resize- Optional. Array with[width, height]for automatic resizing
Returns: Array of filenames or throws UploadException
deleteFile(string $fileName, string $path): void
Delete a file from storage.
Parameters:
$fileName- The filename to delete$path- Storage path
🔧 Advanced Configuration
Using Different Storage Disks
The package respects your FILESYSTEM_DISK environment variable. To use different disks:
Local Storage:
Amazon S3:
DigitalOcean Spaces, Cloudinary, etc.:
Configure your disk in config/filesystems.php and set FILESYSTEM_DISK accordingly.
Restrict File Extensions
Edit config/stup-image.php:
Disable Filename Hashing
If you want to keep original filenames:
🛡️ Security
- Filenames are hashed by default using MD5 + timestamp to prevent conflicts and enhance security
- File extension validation prevents unauthorized file types
- Uses Laravel's Storage facade for secure file handling
📝 Examples
Complete CRUD Example
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
This package is open-sourced software licensed under the MIT license.
👨💻 Credits
- Author: Wirandra Alaya (dayCod)
- Intervention Image: Intervention
💬 Support
If you find this package helpful, please consider giving it a ⭐ on GitHub and Packagist!
For issues or questions, please use the GitHub Issues page.