- How do I install smirltech/laravel-media in a Laravel application?
- Install it with Composer using composer require smirltech/laravel-media. Then follow the repository's installation steps, which may include publishing configuration, running migrations, or linking storage depending on the package version. Always check the README for the exact setup sequence.
- How do I attach an uploaded file to an Eloquent model using laravel-media?
- The package is built to associate media with Eloquent models, so you typically add its media trait or relationship to the model and pass an uploaded file through the package API. Use the exact trait, relationship, and attachment method names documented in the repository README. Validate the upload with Laravel's file validation rules before attaching it.
- Can one Eloquent model have multiple media files with this package?
- The package is designed to manage media assets attached to Eloquent models, and its relationship API is what determines whether a model exposes one file or a collection. Check the README for single-file and multiple-file relationship examples. If your model needs many assets, use the documented collection relationship rather than storing paths manually.
- How do I get a URL for media attached to a model?
- Media URLs generally come from the configured filesystem disk, so use the package's documented URL accessor or Laravel's Storage facade to generate them. For public local disks, run php artisan storage:link so the files are web-accessible. Confirm the disk visibility and URL behavior in the package configuration.
- Which Laravel and PHP versions does smirltech/laravel-media support?
- Check the package's composer.json for its illuminate/support and PHP constraints, because those define the supported Laravel and PHP versions. The README may also list tested versions. Let Composer resolve the package against your application's Laravel version before committing.
- Where does laravel-media store uploaded files and can I change the disk?
- Uploads are stored on Laravel filesystem disks, so the package configuration and config/filesystems.php control the location. You can usually switch between local public storage, S3, or another disk by changing the configured disk. Keep public and private media separated and set visibility deliberately.
- How do I write tests for media uploads with laravel-media?
- Use Laravel's UploadedFile::fake() to simulate uploads and Storage::fake() to avoid touching real disks in tests. Then assert both the database records and the stored files using the package's documented model setup. Check the README for any required traits or migrations in the test database.
- Does smirltech/laravel-media support image resizing or thumbnails?
- The package description focuses on storing and associating media rather than image manipulation. Verify in the README whether image conversions or thumbnails are supported in your version. If not, pair the package with an image processing library or handle resizing before attachment.
- Is smirltech/laravel-media suitable for production use?
- Yes, it can be used in production when you configure disks, visibility, validation, and backups correctly. Pay attention to upload size and MIME validation, storage permissions, CDN or cache behavior, and whether processing should run in queues. Review the package's maintenance status and test your specific workflow before deployment.
- How does smirltech/laravel-media compare to Spatie laravel-medialibrary and is it maintained?
- Spatie laravel-medialibrary is a common alternative with a broader feature set, including image conversions, while smirltech/laravel-media focuses on a simple way to attach and retrieve media. Compare documented features, Laravel version support, and recent repository activity before choosing. Check Packagist and GitHub for the latest release and maintenance signals.