- What does eyadhamza/laravel-webp do?
- eyadhamza/laravel-webp is a Laravel package for converting images to WebP and serving optimized WebP versions in Laravel applications. Its stated goal is to reduce image file sizes, improve page load performance, and fit WebP handling into an existing Laravel workflow with minimal setup. It is a presentation-layer image optimization utility rather than a full image CDN or media platform.
- Is laravel-webp compatible with Laravel 11 and Laravel 12?
- The package's last release was 2023-12-06, and the assessment found no evidence of Laravel 11 or Laravel 12 compatibility. Before adopting it on a current LTS, check the declared laravel/framework and php constraints in composer.json and test installation in a clean project. You may need to pin an older Laravel version or vendor and patch the package.
- How do I install laravel-webp in a Laravel application?
- Installation is typically done through Composer, followed by publishing any package config and registering or attaching the provided middleware if it is not auto-discovered. The overview describes minimal setup, but you should confirm the exact service provider, config publishing, cache path, disk, and quality settings in the repository. Verify those steps against your Laravel version before rolling it out.
- What PHP extension or binary does laravel-webp need for WebP conversion?
- WebP encoding requires a runtime dependency such as PHP's GD compiled with WebP support, Imagick with a WebP-capable delegate, or the cwebp binary on the host. That means the practical requirement spans your container image and platform build, not just composer.json. Confirm which engine the package uses and whether it is already present in your base image or Laravel Sail environment.
- Does laravel-webp convert images synchronously during requests?
- The assessment warns that if conversion happens synchronously inside middleware on a cache miss, the first request for each asset pays the encode cost. On a cold cache after deployment, that can create a thundering-herd risk and couple image delivery latency to image encode CPU. Check whether the package dispatches a job or offers a pre-warm command before using it in production.
- Does laravel-webp set Vary: Accept and correct cache headers?
- This is a critical production check because the package serves different bytes based on the client's Accept header. If it does not emit Vary: Accept, a shared CDN or reverse proxy may serve WebP to clients that cannot render it. Verify the emitted Content-Type, cache headers, and Vary behavior in your own environment, especially behind a CDN.
- How does laravel-webp handle cache invalidation when source images change?
- The assessment flags stale derivatives, unbounded cache growth without eviction, and unclear invalidation as risks. It asks whether the package uses mtime comparison, hashing, or nothing at all when a source asset is replaced. You should inspect the implementation and plan for cache eviction and invalidation before adopting it.
- Is laravel-webp actively maintained and safe for production?
- Treat it as unmaintained until proven otherwise: the assessment notes a single maintainer, negligible contributor base, no published security policy, 19 stars, and a last release in December 2023. The code complexity may be low, but the maintainership risk is the dominant concern. For production, vendor the package or fork it and own the maintenance.
- Does laravel-webp have test coverage and CI for multiple Laravel versions?
- The assessment found no evidence of a test suite or CI running against multiple Laravel versions, and no evidence of PHP 8.3/8.4 or Windows/Sail parity coverage. Before relying on it, check the repository for tests, GitHub Actions workflows, and version matrix coverage. If coverage is absent, add your own integration tests around conversion, headers, and cache behavior.
- When should I avoid laravel-webp and what alternatives exist?
- It is a poor fit for headless or API-only backends, image-heavy media platforms, and apps already using an image CDN such as Cloudinary, Imgix, or Cloudflare Images. For those cases, keep image transformation out-of-band in a queue, at build time, or in the CDN. Alternatives include intervention/image with your own middleware, a dedicated image CDN, or framework/package solutions that are actively maintained.