Download the PHP package nova-horizons/laravel-openapi-sdk-generator without Composer

On this page you can find all versions of the php package nova-horizons/laravel-openapi-sdk-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-openapi-sdk-generator

laravel-openapi-sdk-generator

CI Latest Version on Packagist

[!WARNING] Beta. This package is under active development ahead of a 1.0 release — the generator CLI, config format, and shape of generated code may change between releases. Feedback and issues are welcome at nova-horizons/laravel-openapi-sdk-generator.

Generates Laravel-native API clients from OpenAPI 3.0/3.1 specs: Http client under the hood, Illuminate\Support\Collection returns, final readonly DTOs with native backed enums, Illuminate\Support\Carbon dates, and zero runtime dependencies beyond what every Laravel app already ships.

Generated output passes Pint and PHPStan level 9 and 10 (max) out of the box. A generated Cast support class narrows mixed wire values with runtime checks — no blind casts — and throws UnexpectedValueException when a response doesn't match the spec. Every resource method carries @throws tags for RequestException and ConnectionException.

How it works

The intermediate representation (src/Ir) keeps spec parsing and code emission fully decoupled — naming rules, allOf flattening, and inline-schema hoisting all happen in the Mapper and are testable without generating a single file. Generated code is committed and reviewed like any other diff; see examples/ for two complete generated SDKs (from the specs in tests/fixtures/).

Setup & generation

Two ways to run the generator, depending on which side of the API you sit on.

From the producer API (push model)

For teams that own both the API and its Laravel consumers: install in the producer, and one command refreshes the SDK in every consumer checkout — regenerating the spec first, so it can never be stale.

Each consumer declares its SDKs in its own composer.json — the repo that owns the generated code owns its configuration. Entries are keyed by each producer's API id, so one consumer can hold SDKs for several APIs:

namespace and out (relative to the consumer root) are required. format is any shell command, run from the consumer's root with {out} substituted — php-cs-fixer, a Sail-wrapped invocation, whatever that project uses; when omitted, the consumer's vendor/bin/pint runs if present, and "format": false disables the step.

The producer declares its id and where consumer checkouts live; machine-specific paths stay out of version control — config/sdk-generator.php reads them from .env:

Then:

The command runs the pregenerate hook first (default l5-swagger:generate, so the spec is always fresh), generates into each consumer's out path, formats with the consumer's own toolchain, and warns if the consumer's config file doesn't seem to define the services.{brand} entry the generated client reads.

Standalone, from a spec file (pull model)

Anywhere you have a spec — including inside a consumer that pulls a published spec itself:

Optional flags: --config-key=services.orbit (where the client reads its URL/key from) and --allow=missing-error-schema,untyped-response (tolerate specific spec violations — see below).

Using the generated SDK

Client & container

Collections & lazy pagination

Endpoints returning DTO lists return Illuminate\Support\Collection. Offset/limit list endpoints also get a {method}Lazy() sibling returning a LazyCollection that auto-pages during iteration.

Exceptions

Every SDK gets its own hierarchy under Exceptions\ — catch (OrbitException $e) catches anything the SDK throws. RequestException/ConnectionException extend Illuminate's, so existing catch sites keep working. When the spec documents error bodies with a single schema, RequestException::error() returns the typed payload. Responses that defy the spec throw UnexpectedResponseException with the exact wire path (Beacon.fixes[]: expected array, got string).

Partial updates (the Omitted sentinel)

Request-only DTOs use Omitted::Value as the default so PATCH semantics survive:

This matches Laravel servers that call $request->validated() and update with the result: omitted keys are untouched, explicit nulls are written.

Testing fakes

Testing\{Brand}Fake ships wire-array factories per DTO (seeded from spec examples) and an Http::fake URL pattern constant per operation — Http::fake() works exactly as in first-party code, because resources call through PendingRequest:

Naming

Wire names are preserved in transport; PHP names strip leading underscores and camelCase on _ boundaries, keeping embedded capitalisation — which keeps them readable for APIs that leak legacy database column conventions into the wire format: __rec_SerialNumber → $recSerialNumber, calc_TotalDueUSD → $calcTotalDueUSD. Collisions are a generation-time error.

Auth

If the spec declares an apiKey/bearer security scheme it is honoured; otherwise Client::make(..., apiKey:) sends the configured defaultApiKeyHeader (X-Api-Key). Document the scheme in L5-Swagger with:

Spec support & limits

Handled: $ref (schemas/parameters/requestBodies/responses), allOf (flattened, not inheritance), inline schema hoisting with structural dedupe (title wins when present), nullable, additionalProperties maps, property enums → native backed enums, format: date/date-time → Illuminate\Support\Carbon, path+query parameters, JSON request/response bodies.

Degraded deliberately: oneOf/anyOf → mixed (with a generation warning), inline query-param enums → documented strings, non-JSON bodies → skipped with a warning (use $client->http).

Strict by default: generation fails on spec-quality problems that degrade the SDK (undocumented error bodies, untyped {} responses, missing operationIds, …), each violation naming the fix. --allow=<rule> (or "allow" in the consumer manifest) downgrades specific rules to visible warnings.

Development

The CI contract for changes: regenerate examples/, and the output must pass Pint --test and PHPStan level 10.

License

MIT. Generated output belongs to you: code this tool generates from your specs carries no license obligation to this package.


All versions of laravel-openapi-sdk-generator with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
devizzent/cebe-php-openapi Version ^1.1.5
nette/php-generator Version ^4.2.2
illuminate/support Version ^12.66 || ^13.0
illuminate/console Version ^12.66 || ^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nova-horizons/laravel-openapi-sdk-generator contains the following files

Loading the files please wait ...