sdk-generator / themealdb-sdk
Unofficial PHP SDK for TheMealDB: search meals, look them up, random meals, categories and filters. Generated from a recorded browser session (HAR).
Requires
- php: ^8.4
- sdk-generator/sdk-runtime: ^1.15.0
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
Suggests
None
Provides
None
Conflicts
None
Replaces
- dmorenof/themealdb-sdk: v0.1.1
This package is auto-updated.
Last update: 2026-12-03 22:17:05 UTC
README
Recipes from TheMealDB as typed PHP, generated from a recorded browser session.
Search meals by name or first letter, look one up, get a random one, list categories, areas and ingredients, and filter by them, from TheMealDB and its free test key.
Unofficial. Not affiliated with, endorsed by or supported by TheMealDB. See NOTICE.md.
Why this SDK
- Generated from real traffic. TheMealDB publishes no machine-readable description; the generator read an HTTP Archive of real calls and inferred the operations, parameters and models from it.
- Free test key built into the address: install and call.
- Typed answers. A meal is a
Mealmodel, a search a list of them. - Generated from a recorded browser session (HAR), never edited by hand.
src/is produced by sdk-generator from the HTTP Archive (HAR) of real calls described in contract/SOURCE.md, on top of the shared sdk-runtime: when the source changes you regenerate, you do not patch. - Typed end to end. 6 operations and 11 typed request, answer and model classes. A request is a model whose fields are checked where you assign them (PHP 8.4 property hooks); an answer is a model; a list is a typed collection. PHPStan at the maximum level reports no error on the whole SDK.
- One way to fail. An HTTP answer the contract does not declare as success is an
ApiExceptionthat keeps the raw response and, when the API documents it, the decoded error as a model. Network failures keep their own type. - Production controls included. PSR-18 HTTP client (Guzzle by default), timeouts (30 s / 10 s by default), retries with
Retry-After, redirect policy, middleware and per-environment servers, all in oneConfigurationobject.
Install
PHP 8.4 or later.
composer require sdk-generator/themealdb-sdk
Quick start
<?php use TheMealDbSDK\Configuration; use TheMealDbSDK\GetParams\Search as SearchParams; use TheMealDbSDK\Search; use TheMealDbSDK\ThemealdbComSDK; ThemealdbComSDK::configure(new Configuration()); $params = new SearchParams(); $params->s = 'Arrabiata'; $result = Search::get($params); foreach ($result->meals ?? [] as $meal) { echo $meal->strMeal, ' (', $meal->strCategory, ")\n"; }
The same example is in examples/quickstart.php. Every operation is listed in docs/OPERATIONS.md.
What it covers
6 operations. The biggest areas:
| Area | Operations |
|---|---|
categories.php |
1 |
filter.php |
1 |
list.php |
1 |
lookup.php |
1 |
random.php |
1 |
search.php |
1 |
Handling errors
use Dmorenof\SdkRuntime\ApiException; try { // ... any call from the quick start } catch (ApiException $e) { echo $e->response->status, "\n"; // the HTTP status echo $e->response->body, "\n"; // the raw body, always kept var_dump($e->error); // the decoded error model, when the API documents one }
Configuration
Configuration is the only place to set anything: baseUrl, securityCredentials, headers, timeout, connectTimeout, retryPolicy, redirectPolicy, middleware, httpClient (any PSR-18 client), serverVariables. Use Client::connect($configuration) instead of the static facades when you need several independent connections.
Good to know
- The address includes TheMealDB's public test key
1(/api/json/v1/1), meant for development. For production, TheMealDB asks supporters for a key: set$configuration->baseUrlto the address with yours. - Generated from what the capture shows: an endpoint or field not used in it is not in the SDK, and no field is required.
- Version
0.1.0is a first release: the API of the SDK follows the source description, and a regenerated one can rename classes. Pin a version.
Documentation
- Operations catalog
- Vendor documentation
- sdk-runtime (what every SDK shares) and sdk-generator
- CHANGELOG.md, CONTRIBUTING.md, SECURITY.md
License
MIT, see LICENSE.md. The license covers this SDK's code, not the API, its trademarks or its terms: see NOTICE.md.