Versioning and Upgrades

Upgrading Kipchak

Upgrading Kipchak to the latest version

Introduction

This page lists all the breaking changes introduced by each major version.

There are multiple ways to mitigate these changes, but the safest is to follow the starter project structure and upgrade step by step.

For versioning information, please see Versioning.

Validation: rules written once (core 3.19)

Core 3.19 adds Dto\Field, Dto\Check and Dto\Input, and Error middleware 1.36 adds meta.errors to the response for an invalid body. No breaking change is involved: a DTO that does not use them behaves as before, and OA\Property is still not enforced. The data string keeps its place and type, so clients that read it are unaffected.

To adopt them, composer require kipchak/core:^3.19 kipchak/middleware-error:^1.36 and composer require --dev kipchak/cli:^1.3. Then, one DTO at a time:

  1. Change the properties that have rules from OA\Property to Field. Those rules will start to refuse request bodies, so check that each one is what you mean to enforce.
  2. Read the request body with Input::from($request, Dto::class, ['id' => 0]), and remove the controller's input() and problems() and the model's handling of MappingError.

A stored row is not checked against the rules: see DTOs. In a project on core 3.19 or later, CLI 1.3 writes new code this way; on an older core it writes the form that compiles there.

Starter 4.6 shows this in its example DTO and tests/ValidationTest.php.

Doctrine driver 1.55: Memcached is optional

A project that uses Memcached may need one new line in composer.json

Doctrine driver 1.55 no longer requires kipchak/driver-memcached. A project that received Memcached only through the Doctrine driver loses it the next time its lock file is updated. If that project calls Memcached::initialise(), it then fails at boot with a class-not-found error. Before updating, run:

composer require kipchak/driver-memcached

You need that command if your project initialises the Memcached driver or sets 'store' => 'memcached' in config/kipchak.doctrine.php, and composer.json does not already require the driver. A project that requires another package which needs Memcached, such as Subashi, still receives it through that package, but should require it explicitly too.

An entity manager with 'store' => 'memcached' and without the driver now fails when the API boots, in development as in production, with a message that names the package to add. Setting the store to 'file' needs no Memcached at all, and installing the Doctrine driver no longer needs ext-memcached.

Status names: one for each refusal (core 3.18)

Until November 2026 one API could name the same refusal two ways. A Kipchak middleware that refused a request itself wrote the HTTP name from Codes (UNAUTHORIZED, FORBIDDEN, TOO MANY REQUESTS), while the Error middleware wrote its own (UNAUTHENTICATED, INSUFFICIENT_PRIVILEGES, TOO_MANY_REQUESTS). Core 3.18 adds Http\ErrorStatus, one table of those names, and Http\Response::error(), which writes the envelope with them. The Error middleware and every Kipchak middleware now use it:

Codestatus
400BAD_REQUEST
401UNAUTHENTICATED
403INSUFFICIENT_PRIVILEGES
404RESOURCE_NOT_FOUND
405NOT_ALLOWED
429TOO_MANY_REQUESTS
501NOT_IMPLEMENTED
any other 5xxSERVER_ERROR
any other 4xxits HTTP name, such as CONFLICT

Released with it: middleware-error 1.35, auth-jwks 1.42, auth-jwt 1.35, auth-key 1.41, auth-hmac 1.10, policy 1.3, feature-flags 1.5, idempotency 1.5, quotas 1.8 and subashi 1.39. What changes for a client:

  • A refusal from those middlewares carries the names above instead of the HTTP names. A client that compares status needs the new names; one that switches on the code, or on a middleware's own error field, is unaffected.
  • The Error middleware names a 4xx it has no name for by its HTTP name (CONFLICT) instead of SERVER_ERROR.
  • auth-jwks and auth-jwt answer a valid token that lacks a required scope with 403, not 401 (RFC 6750). A client that treats every 401 as "sign in again" now shows a refusal for that case instead.
  • auth-jwt answers a token that fails verification with 401 Invalid token, not 400 with the library's message.
  • auth-jwks has key_set_ttl, how long a key set is trusted; set it to 3600 or less.

Codes and Response::json() are unchanged, so what an API's own routes write does not change. To give a route's own refusal the same name, use Response::error(), or throw a Slim HTTP exception for the Error middleware:

return Http\Response::error($response, 'This order belongs to another account.', 403);
// {"code": 403, "status": "INSUFFICIENT_PRIVILEGES", "data": "This order belongs to another account."}

Starter 4.5: Kipchak CLI 1.2

Starter 4.5 requires Kipchak CLI 1.2, whose make: commands write responses in the short form when the project registers the Envelope processor: a success declares only its data, and a 404 a description with no content. The starter therefore no longer defines the shared NotFound response in api/OpenApi/Definition.php. Its tests/ScaffoldTest.php scaffolds a resource with the installed CLI, under a name no project has, and checks that the document stays valid.

No breaking change is involved. Update an existing project with composer require --dev kipchak/cli:^1.2. Keep the NotFound response while any controller still refers to #/components/responses/NotFound; kipchak openapi:validate reports a reference that does not resolve.

Starter 4.4: the response envelope in the OpenAPI document

Starter 4.4 requires kipchak/core 3.17.1 and registers its Envelope processor in api/Utils/OpenApi.php, so that the OpenAPI document states responses as the API sends them. A controller now declares only the data, such as new OA\JsonContent(ref: '#/components/schemas/MamlukSultan'), and the document states the envelope around it. A 4xx or 5xx response that declares no content is given the error envelope of the Error middleware. See The response envelope in the document.

No breaking change is involved, and the responses themselves are unchanged. To adopt it in an existing project:

  1. Run composer require kipchak/core:^3.17.1.

  2. In api/Utils/OpenApi.php, add the processor to the generator:

    $document = new Generator(self::problemsOnly($logger))
        ->withProcessorPipeline(fn (Pipeline $pipeline) => $pipeline->add(new Envelope(errors: true)))
        ->generate([dirname(__DIR__)]);
    

    with use Kipchak\Core\OpenApi\Envelope; and use OpenApi\Utils\Pipeline;.

  3. Optionally, replace inline envelopes in controllers with the data alone. An operation that already spells out code, status and data is left as it is, so this step can be done one controller at a time.

Starter 4.3: Kipchak CLI 1.1 and a Status schema

Starter 4.3 requires Kipchak CLI 1.1, which adds the make: commands, routes and openapi:validate. Update an existing project with composer require --dev kipchak/cli:^1.1.

It also describes the /status response with a DTO, api/DataTransferObjects/ApiStatus.php, instead of an inline object, so that kipchak openapi:validate --strict passes on a new project. The response itself is unchanged. No breaking change is involved, and an existing project needs neither change.

Starter 4.1: initialise the Error middleware first and last

Starter 4.1 corrects advice that this documentation, the starter and the examples repository gave until 3 November 2026: to initialise the Error middleware first in middlewares/middlewares.php. Slim runs the middleware added last first, so the Error middleware initialised first is the innermost middleware. It handles an exception thrown by a route, but not one thrown by a middleware initialised after it. Such an exception reached the worker in html/index.php, and the client received a plain-text 500 with the exception's message instead of a JSON error response.

No breaking change is involved. In an existing API, add a second Error::initialise($app); as the last line of middlewares/middlewares.php, and keep the first:

Error::initialise($app);   // innermost: turns route exceptions into JSON responses
Key::initialise($app);     // ... every other global middleware
Subashi::initialise($app);
Error::initialise($app);   // outermost: does the same for exceptions from the middleware above

The first keeps route errors as responses that middleware such as OpenTelemetry, Metering, Redaction and Idempotency observe; the last catches whatever any other middleware throws. Starter 4.1 also adds tests/MiddlewareOrderTest.php, which fails if the Error middleware is not the outermost; copy it, with the app() method it uses in tests/ApiTestCase.php, into an existing project to keep the order checked.

Starter 4.1 also adds the two use statements the commented Doctrine lines in html/index.php need (Doctrine\DBAL\Exception\ConnectionException and ConnectionLost). Without them, the uncommented catch never matches and a lost database connection is not replaced.

Upgrading from 2.x to 3.x

Upgrading from version 2.x to 3.x is a major release. It adds support for PHP 8.5 while retaining PHP 8.4 compatibility, so the runtime upgrade itself is straightforward — the starter's Dockerfile moves from the PHP 8.4 image to the PHP 8.5 image.

The breaking changes come from bundled dependencies being upgraded to new major versions.

Changes include:

  • PHP 8.5 support. The starter now runs on the PHP 8.5 FrankenPHP image. PHP 8.4 remains fully supported.
  • CuyZ Valinor upgraded from 1.x to 2.x. Only affects you if you use Valinor directly (for example in a DTO). The standard mapping flow — (new MapperBuilder())->mapper()->map(...) with Source::array() — is unchanged. Breaking removals: MapperBuilder::alter() (replaced by mapper converters), MapperBuilder::enableFlexibleCasting(), and MapperBuilder::warmup() (renamed to warmupCacheFor()). The Normalizer API moved to a dedicated NormalizerBuilder. See the Valinor upgrade guide.
  • Zircote Swagger PHP upgraded from 5.x to 6.x. If you document your API with PHP attributes (#[OA\Schema], #[OA\Property], ...) — as the starter does — no changes are needed. The legacy doctrine-annotation style is deprecated in 6.x; migrate any remaining annotations to attributes.
  • Dependency constraints widened. Core is now 3.0. All drivers and middlewares now accept kipchak/core: ^2 || ^3, so you can adopt core 3.x incrementally.
  • New: response metadata envelope. Http\Response::json() accepts an optional meta argument for pagination, counts, and similar endpoint metadata. It sits between status and data in the response envelope. This is additive and fully backward compatible.

Breaking driver releases

Three drivers had their underlying SDKs upgraded across breaking major versions and were released as new majors of their own. If you use any of them, bump your constraint to allow the new major (^1 || ^2):

  • kipchak/driver-http 2.0 — upgraded illuminate/http from 12.x to 13.x. The driver's public API is unchanged.
  • kipchak/driver-anthropic 2.0 — upgraded anthropic-ai/sdk from 0.6 to 0.36. The driver's max_retries config key and message API are unchanged. If you call raw() to use the SDK directly, review the SDK's changes.
  • kipchak/driver-openai 2.0 — upgraded openai-php/client from 0.10 to 0.20. The driver API is unchanged. If you call raw(), review the client's changes.

Upgrading from 1.x to 2.x

Upgrading from version 1.x to 2.x is a major release and has breaking changes.

It introduces interfaces for writing Drivers and Middleware and slightly changes the bootstrapping process.

Changes include:

  • Package name has changed from mamluk/kipchak to kipchak/core
  • Namespace has changed from Mamluk\Kipchak to Kipchak\Core
  • The project has been restructured to be more modular and has thus introduced:
  • Interfaces have been added to make it easier to write drivers and middlewares
  • The starter repository has been updated to use the new structure
  • Middlewares and Drivers now initialise with a single method and must be registered in middlewares/middlewares.php and drivers/drivers.php, respectively.
  • The base controller name has changed from Slim to Base and now ONLY includes the Logger driver.
  • Bootstrapping has been simplified for faster boot times.
  • The html/index.php entrypoint now uses FrankenPHP's worker mode.
  • You will have to update your composer.json file to use just those drivers and middlewares you need, as opposed to everything that was bundled into the core before.
  • Instead of using $container->get() to now get any dependencies in the container, use Driver::get().

Upgrading from 0.x to 1.x

Upgrading from version 0.x to 1.x is a major release and has breaking changes.

This means:

  • Support for PHP 8.4.
  • You will have to manually use the session management middleware as it has been removed from the core.
  • Zircote Swagger is now part of the core.
  • Doctrine has been upgraded to version 3.5+. This may result in breaking changes, especially:
    • for migrations and if you were using / extending some core Doctrine capabilities without specifying return types.
    • for the Doctrine ORM if you use Doctrine proxies (in this case you will need to remove the proxies.sh script from your bin/ folder and remove its execution from your Dockerfile). Proxies are generated automatically in 3.5+ at runtime as needed.
  • Upgrade to the new Doctrine cli (which is available in the bin/ folder of the starter project) created for Kipchak. The prebuilt cli command was removed in Doctrine 3.5.
Previous
Versioning