Skip to content

PHP Api improvements - #8

Merged
victorycodedev merged 5 commits into
mainfrom
feature/php-api-improvements
Sep 3, 2026
Merged

PHP Api improvements#8
victorycodedev merged 5 commits into
mainfrom
feature/php-api-improvements

Conversation

@victorycodedev

Copy link
Copy Markdown
Owner

What changed?

  • Added Fetch::macro() support using Laravel’s Macroable trait.
  • Added baseUrl() support for requests and downloads.
  • Added Laravel when() and unless() support through Conditionable.
  • Added common HTTP status helpers to FetchResponse, including created(), notFound(), unauthorized(), unprocessableEntity(), statusIs(), and others.
  • Made these existing NativePHP lifecycle events globally observable through Laravel:
    • FetchRequestStarted
    • FetchRequestCompleted
    • FetchRequestFailed
  • Preserved existing NativeComponent #[On(...)] event handling and payloads.
  • Kept cancellation, retry, progress, and download-completed events component-only.
  • Updated documentation for macros, base URLs, response helpers, global listeners, downloads, and event behavior.
  • Added test coverage for the new APIs, event broadcasting, native/component compatibility, downloads, retries, and event payloads.
  • Corrected PHP formatting enforced by CI.

Why?

These changes improve the PHP API’s ergonomics and extensibility while staying consistent with familiar Laravel conventions.

Application-wide listeners can now observe the main request lifecycle without replacing or changing existing NativePHP component listeners. The implementation uses NativePHP’s existing BroadcastsGlobally mechanism, avoiding additional callback infrastructure or changes to the native bridge.

How was it tested?

The following automated checks passed:

  • composer test
    • 135 tests
    • 560 assertions
  • composer format:check
  • composer analyse
  • composer validate --strict
  • npm test --prefix resources/js
    • 17 JavaScript tests
  • npm run syntax --prefix resources/js
  • npm run format:check --prefix resources/js
  • npm run docs:build --prefix docs
  • git diff --check

Tests also verify that:

  • Global Laravel listeners receive the three selected lifecycle events.
  • Existing #[On(...)] component listeners continue receiving the same events.
  • Event constructors and payloads remain unchanged.
  • Downloads participate in started and failed events.
  • Internal retries do not emit additional started events.
  • No Android, iOS, bridge, or manifest behavior was changed.

Platforms tested

  • PHP
  • JavaScript
  • Android
  • iOS
  • Not applicable / documentation only

Breaking changes?

None.

All existing public APIs, event names, constructors, payloads, request IDs, bridge calls, and NativeComponent #[On(...)] signatures remain compatible.

Checklist

  • Tests were added or updated where appropriate.
  • Existing relevant tests pass.
  • Documentation was updated where necessary.
  • Public API and event/bridge compatibility were considered.
  • Android/iOS behavior parity was considered where relevant.
  • No unnecessary native dependencies were introduced.
  • No secrets, tokens, temporary logging, or debugging code were committed.
  • Native changes were tested in a generated NativePHP application where practical.

@victorycodedev
victorycodedev merged commit 2d61bcf into main Sep 3, 2026
10 checks passed
@victorycodedev
victorycodedev deleted the feature/php-api-improvements branch September 3, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant