Br install and migrate

From Lonsdale201/wp-agent-skills · View interactive version

Br install and migrate is an AI agent skill from the GitHub repository Lonsdale201/wp-agent-skills. Install better-route from Packagist or migrate an existing WordPress API to Better Route 2.0 on PHP 8.3. Use for Composer constraints, choosing the PHP 8.1-compatible 1.1.3 security patch, upgrading web/CLI/worker runtimes, readonly DTO compatibility, or preserving earlier authentication, idempotenc

How to use this skill

Skill file

better-route: install and migrate

Install

Choose the package line for the actual PHP runtime. Better Route is a Composer

library, not an independently activated WordPress plugin.

composer require better-route/better-route:^2.0
composer show better-route/better-route
composer check-platform-reqs --no-dev

Version 2.0 requires PHP 8.3 in web, CLI, cron and worker processes. For PHP 8.1/8.2,

use the security-patched 1.x line with composer require better-route/better-route:^1.1.3.

On 1.1.2 or older, replace the Resource ownership helper with an explicit URL-bound

policy until updated; see br-owned-resource-guards.

An existing ^1.1 constraint deliberately does not select 2.0. Do not add a VCS

repository unless intentionally consuming a fork or unreleased branch.

Register routes during rest_api_init:

use BetterRoute\Router\Router;

add_action('rest_api_init', static function (): void {
    $router = Router::make('myapp', 'v1');
    $router->get('/ping', static fn (): array => ['pong' => true])
        ->publicRoute();
    $router->register();
});

1.1.2 / 1.1.3 to 2.0.0

config.platform value does not upgrade the server; check real platform requirements.

fields and constructors remain; attaching undeclared properties now fails. Use

RequestContext::withAttribute() or separate application state. Readonly is shallow.

Messages, object properties and onward PHP/WP/custom callback frames are outside

that protection. Annotate sensitive parameters in custom implementations too.

values remain unchanged. No database-schema, cache-key or idempotency-key migration

is introduced between 1.1.2 and 2.0.0.

preventing query/body IDs from selecting a different authorization object.

The same security fix is available in 1.1.3 without raising the PHP minimum.

library major. Installing 2.0 does not require renaming an unchanged myapp/v1 API.

Use br-php83-upgrade for runtime and extension compatibility checks.

1.1.1 to 1.1.2

This earlier upgrade remains relevant when jumping directly to 2.0:

Privileged multi-role, directly privileged and superadmin users are excluded by

default. Role filters only narrow trusted configuration. Authorization/session

metadata is rejected, including known sensitive keys without an underscore prefix.

create/update responses can include filtered public metadata by default. Coupon state is a management summary;

published default lists still include expired/exhausted coupons unless filtered.

Internal coupon metadata cannot invoke native setters; usage counts remain read-only.

import-readiness checks and no cross-user wrapper cache. Use br-woo-analytics.

Invalid security, duplicate operations and equivalent path templates throw. Use

strict export and a complete OpenAPI 3.1 validator; handle native WP errors too.

writer rollout below when coming from 1.1.0 or earlier.

1.1.0 to 1.1.1

Keep Composer versions, your REST namespace and OpenAPI info.version independent. Updating the library does not rename myapp/v1. This patch fixes existing APIs; it adds no Store API, cart, checkout or refund endpoints.

Coordinate cache and idempotency key changes

Default response-cache keys and both classic/atomic idempotency keys and fingerprints now include router namespace, template, concrete request path and separately captured URL parameters. Query/body fields cannot mask a URL ID in this scope. RequestContext::routePath remains the template; the router supplies attributes['routeNamespace'].

Old response-cache entries become cold and expire. Old default idempotency records lack the namespace/target needed for safe translation; there is no legacy replay fallback. No table-schema change is needed from 1.1.0.

  1. Pause all affected writers, webhooks, retry queues and client retries; drain in-flight requests.
  2. Reconcile uncertain operations against business records. Complete or retire old retries before switching keys. Account for the entire client retry horizon; waiting for record TTL alone is insufficient.
  3. Switch every web/worker process together and restart long-running workers. Never mix old/new default key schemes.
  4. Verify identical replay and payload conflicts, then resume new operations. Retain business-level deduplication for irreversible effects.

Do not clear records as a substitute for reconciliation. Rollback requires the same coordination. Custom key/fingerprint resolvers own namespace, URL, identity and tenant isolation; a custom key alone still uses the changed default fingerprint. Keep auth before cache/idempotency. Rate-limit buckets, optimistic-lock scope and single-use token semantics are unchanged.

Review authentication and Woo changes

1.0.x to 1.1.x migration checklist

Also follow the 1.1.1 rollout above when upgrading directly from 1.0.x.

Treat these as consumer-visible changes when moving from ^1.0 to ^1.1.

Routing

Identity, cache, and throttling

Idempotency and optimistic locking

Resource DSL

CORS, ETag, errors, and telemetry

JWT and JWKS

OpenAPI

WooCommerce

Older migrations still in force

When upgrading from pre-1.0, also preserve these established contracts:

Verify

Run the package checks and then live REST smoke tests against the host stack:

composer test
composer analyse
composer cs-check

Smoke at minimum: anonymous/public and denied routes, authenticated reads/writes, CORS preflight, conditional ETag 304, rate-limit 429 headers, repeated/concurrent idempotent writes, OpenAPI generation, Resource pagination/visibility, and Woo writes with HPOS enabled.

Related skills

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.