Download the PHP package laratusk/pictomock without Composer
On this page you can find all versions of the php package laratusk/pictomock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package pictomock
PictoMock
PictoMock is a lightweight, framework-agnostic PHP library for generating fake placeholder images — perfect for testing, seeding databases, and prototyping. It supports SVG (zero dependencies), PNG, JPEG, GIF, WebP, and WBMP via the GD extension, with a clean fluent API and first-class Laravel and FakerPHP integration.
Features
- Generate placeholder images in SVG, PNG, JPEG, GIF, WebP, WBMP
- SVG generation requires no GD extension — works anywhere PHP runs
- Fluent, immutable builder API for readable configuration
- Simple static API for one-liners
- Background color strategies: random solid color, fixed hex color, two-color gradient
- Optional text overlay showing image dimensions (e.g. "400x300")
- Laravel service provider, facade, and publishable config
- FakerPHP provider for seamless integration with Faker-based factories
- PHP 8.1+, strict types, PSR-4, PSR-12
Installation
For raster image formats (PNG, JPEG, GIF, WebP, WBMP) the PHP GD extension is required:
Quick Start
Usage
Static API
Signature:
Fluent API
The builder is immutable — each method returns a new instance, making it safe to fork:
Background Strategies
Random Color (default)
Fixed Color
Gradient Color
The gradient is rendered left-to-right for GD images and as an SVG linearGradient for SVG output.
Text Overlay
Add the image dimensions as a centered text label:
SVG Generation (no GD required)
The SVG generator uses PHP's built-in DOMDocument and requires only ext-dom.
Laravel Integration
Auto-Discovery
The service provider and facade are auto-discovered via composer.json extra.laravel. No manual registration needed for Laravel 5.5+.
Publish Config
This publishes config/pictomock.php to your application.
Facade
Config Reference
Database Factories with FakerPHP
Register the provider in your AppServiceProvider or a dedicated faker service provider:
Then use it in factories:
FakerPHP Integration (Standalone)
Available Faker Methods
| Method | Description |
|---|---|
pictoMock(int $w, int $h, string $format, bool $text) |
Generate image and return file path |
pictoMockUrl(int $w, int $h, string $format) |
Generate image and return data URI |
ImageFormat Enum
All supported formats are defined in Laratusk\PictoMock\Enums\ImageFormat:
| Case | Value | MIME Type | Requires GD |
|---|---|---|---|
ImageFormat::SVG |
svg |
image/svg+xml |
No |
ImageFormat::PNG |
png |
image/png |
Yes |
ImageFormat::JPG |
jpg |
image/jpeg |
Yes |
ImageFormat::JPEG |
jpeg |
image/jpeg |
Yes |
ImageFormat::GIF |
gif |
image/gif |
Yes |
ImageFormat::WEBP |
webp |
image/webp |
Yes |
ImageFormat::WBMP |
wbmp |
image/vnd.wap.wbmp |
Yes |
Testing
Run only unit tests:
Run only integration tests:
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Write tests for your changes
- Ensure all tests pass (
./vendor/bin/phpunit) - Follow PSR-12 coding standards
- Submit a pull request
Please open an issue before implementing large changes.
License
The MIT License (MIT). See LICENSE for details.
All versions of pictomock with dependencies
ext-dom Version *