zpmlabs / undraw-php
Tiny client for undraw.co search (Next.js data routes) returning DTOs and SVG code on demand.
Installs: 5
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/zpmlabs/undraw-php
Requires
- php: ^8.1
- php-http/discovery: ^1.19
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0 || ^2.0
- psr/simple-cache: ^3.0
Suggests
- guzzlehttp/guzzle: ^7.0 || ^8.0
- guzzlehttp/psr7: ^2.6
- nyholm/psr7: ^1.8
- symfony/cache: ^6.0 || ^7.0
README
Lightweight client for undraw.co search (using Next.js data routes).
Returns typed DTOs and lets you fetch SVG code.
Install
composer require ZPMLabs/undraw-php # You also need a PSR-18 client & PSR-17 factories (Discovery will find them). # Example: composer require guzzlehttp/guzzle nyholm/psr7
Usage
use Undraw\Factory\UndrawFactory; $client = UndrawFactory::create(); // in-memory cache by default $results = $client->search('music', 10); // array of Undraw\DTO\Illustration foreach ($results as $i) { echo $i->title . ' => ' . $i->mediaUrl . PHP_EOL; $svg = $client->getSvg($i); // raw SVG string }
With Laravel
use Undraw\Factory\UndrawFactory; use Undraw\UndrawClient; use Undraw\Support\Laravel\LaravelCacheAdapter; app()->bind(UndrawClient::class, function () { return UndrawFactory::create(new LaravelCacheAdapter()); });
With Filament
Select::make('undraw_media') ->searchable() ->getSearchResultsUsing(function (string $search) { /** @var \Undraw\UndrawClient $u */ $u = app(\Undraw\UndrawClient::class); return collect($u->search($search, 20)) ->mapWithKeys(fn($i) => [$i->mediaUrl => $i->title]) ->all(); }) ->hint('Search undraw…');