Media Library - v1.0-beta1
Troubleshooting
Common issues and solutions for the Media Library package.
Installation Issues
Composer Install Fails
Problem: composer require artisanpack-ui/media-library fails
Solutions:
-
Clear Composer cache:
composer clear-cache composer require artisanpack-ui/media-library --no-cache -
Check repository configuration in
composer.json -
Verify PHP version:
php -v # Should be 8.2 or higher
Migration Fails
Problem: php artisan migrate fails with database errors
Solutions:
- Check database connection in
.env - Ensure database user has CREATE TABLE permissions
- Check for existing tables with same names:
php artisan db:show - Review error messages for specific issues
Storage Link Fails
Problem: php artisan storage:link fails or doesn't work
Solutions:
-
Check directory permissions:
chmod -R 775 storage/ chmod -R 775 public/ -
Manually create symlink:
ln -s ../storage/app/public public/storage -
On Windows, run as administrator:
mklink /D public\storage ..\storage\app\public
Upload Issues
File Upload Fails
Problem: Files fail to upload with no error message
Solutions:
-
Check PHP upload limits in
php.ini:upload_max_filesize = 20M post_max_size = 25M max_execution_time = 300 memory_limit = 256M -
Check web server limits:
Nginx:
client_max_body_size 20M;Apache:
LimitRequestBody 20971520 -
Restart PHP-FPM/web server after changes
"Permission Denied" Error
Problem: Upload fails with permission error
Solutions:
-
Check storage directory permissions:
chmod -R 775 storage/app/public chown -R www-data:www-data storage/ -
Check parent directory ownership
-
Verify storage disk configuration in
config/filesystems.php
Invalid File Type Error
Problem: File rejected as invalid type
Solutions:
-
Check allowed MIME types in configuration:
config('artisanpack.media.allowed_mime_types') -
Verify file extension matches MIME type
-
Check for corrupted files
Image Processing Issues
Thumbnails Not Generating
Problem: Images upload but thumbnails don't generate
Solutions:
-
Check if GD or Imagick is installed:
php -m | grep -i gd php -m | grep -i imagick -
Install missing extension:
# GD sudo apt-get install php-gd # Imagick sudo apt-get install php-imagick -
Restart PHP-FPM:
sudo service php8.2-fpm restart -
Check error logs:
tail -f storage/logs/laravel.log
WebP/AVIF Conversion Fails
Problem: Modern format conversion doesn't work
Solutions:
-
Check WebP support:
php -r "echo (imagetypes() & IMG_WEBP) ? 'Supported' : 'Not supported';" -
For AVIF, ensure Imagick is installed and updated:
php -r "if (extension_loaded('imagick')) { echo in_array('AVIF', Imagick::queryFormats()) ? 'Supported' : 'Not supported'; }" -
Update Imagick:
sudo pecl upgrade imagick -
Disable modern formats if not supported:
MEDIA_ENABLE_MODERN_FORMATS=false
Low Quality Images
Problem: Processed images are low quality
Solutions:
-
Increase quality setting in
.env:MEDIA_IMAGE_QUALITY=95 -
Check intervention/image driver:
config('image.driver') // should be 'imagick' for better quality
Video Issues
Video Thumbnails Not Generating
Problem: Videos upload but no thumbnails
Solutions:
-
Check if FFmpeg is installed:
ffmpeg -version -
Install FFmpeg:
# Ubuntu/Debian sudo apt-get install ffmpeg # macOS brew install ffmpeg -
Ensure FFmpeg is in system PATH:
which ffmpeg -
Check logs for FFmpeg errors:
tail -f storage/logs/laravel.log
URL & Display Issues
Media URLs Return 404
Problem: Media files return 404 errors
Solutions:
-
Verify storage link exists:
ls -la public/storage -
Check file actually exists:
ls storage/app/public/media/ -
Verify disk configuration:
config('artisanpack.media.disk') config('filesystems.disks.public') -
Clear Laravel cache:
php artisan cache:clear php artisan config:clear
Images Don't Display
Problem: <img> tags show broken image icon
Solutions:
- Check browser console for errors
- Verify URL is correct:
dd($media->url()); - Check file permissions (should be 644)
- Verify Content-Type header is correct
Performance Issues
Slow Upload Processing
Problem: Uploads take too long to process
Solutions:
-
Use queue for image processing:
php artisan queue:work --queue=media -
Increase PHP limits:
max_execution_time = 600 memory_limit = 512M -
Disable unnecessary image sizes
-
Reduce image quality setting
High Memory Usage
Problem: PHP runs out of memory during processing
Solutions:
-
Increase memory limit:
memory_limit = 512M -
Process images in background queue
-
Reduce maximum image dimensions in configuration
Database Issues
Foreign Key Constraint Fails
Problem: Cannot delete media due to foreign key constraint
Solutions:
-
Check for references in other tables:
SELECT * FROM posts WHERE featured_image_id = 123; -
Remove references before deleting
-
Use soft deletes (enabled by default)
Duplicate Slug Error
Problem: Cannot create folder/tag due to duplicate slug
Solutions:
- The system auto-generates unique slugs
- If error persists, manually specify a unique slug:
MediaFolder::create([ 'name' => 'Products', 'slug' => 'products-2025', ]);
API Issues
401 Unauthorized
Problem: API requests return 401 error
Solutions:
-
Verify token is included in header:
Authorization: Bearer YOUR_TOKEN -
Check token hasn't expired
-
Verify user has required permissions
422 Validation Error
Problem: API upload returns validation error
Solutions:
-
Check Content-Type header:
Content-Type: multipart/form-data -
Verify all required fields are included
-
Check file size limits
Testing Issues
Tests Fail with Database Errors
Problem: Tests fail with "table not found" errors
Solutions:
-
Run migrations in test environment:
php artisan migrate --env=testing -
Use RefreshDatabase trait in tests:
use Illuminate\Foundation\Testing\RefreshDatabase; class MediaTest extends TestCase { use RefreshDatabase; }
Getting Help
If these solutions don't resolve your issue:
- Check Laravel logs:
storage/logs/laravel.log - Enable debug mode temporarily:
APP_DEBUG=true - Search existing issues on GitLab
- Contact support: support@artisanpackui.dev
Next Steps
- Review FAQ for common questions
- Check Installation Guide
- See Configuration options