Skip to content

Open-source the PhpServicePlatform HTTP layer - #1

Merged
hakeemRash merged 4 commits into
mainfrom
master
Jul 22, 2026
Merged

Open-source the PhpServicePlatform HTTP layer#1
hakeemRash merged 4 commits into
mainfrom
master

Conversation

@hakeemRash

@hakeemRash hakeemRash commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Extract the kernel HTTP layer into a standalone MIT-licensed package:
immutable Request/Response value objects, PSR-7 Uri, SiteUri, content
negotiation, Method enum, UserAgent, and FPM-/Swoole-safe UploadedFile.

Add community health files (README, LICENSE, CODE_OF_CONDUCT, CONTRIBUTING,
SECURITY, SUPPORT, issue/PR templates, CODEOWNERS, dependabot), CI matrix
(PHP 8.2/8.3/8.4 -> validate + PHPStan + PHPUnit), phpunit + phpstan config,
tests, and a kernel-styled .gitignore.

Summary by CodeRabbit

  • New Features
    • Introduced a comprehensive HTTP library for immutable request and response handling.
    • Added request parsing, input helpers, URL/URI utilities, content negotiation, HTTP method classification, user-agent parsing, and uploaded-file support.
    • Added convenient response creators for JSON, text, redirects, errors, downloads, and streaming.
  • Documentation
    • Added README, changelog, contribution, support, security, licensing, and community guidelines.
  • Quality & Maintenance
    • Added automated testing, static analysis, continuous integration, and structured issue and pull request templates.

Extract the kernel HTTP layer into a standalone MIT-licensed package:
immutable Request/Response value objects, PSR-7 Uri, SiteUri, content
negotiation, Method enum, UserAgent, and FPM-/Swoole-safe UploadedFile.

Add community health files (README, LICENSE, CODE_OF_CONDUCT, CONTRIBUTING,
SECURITY, SUPPORT, issue/PR templates, CODEOWNERS, dependabot), CI matrix
(PHP 8.2/8.3/8.4 -> validate + PHPStan + PHPUnit), phpunit + phpstan config,
tests, and a kernel-styled .gitignore.
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@hakeemRash, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 32 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 011f06f7-fa6e-4d0a-9e0b-12b8479845f6

📥 Commits

Reviewing files that changed from the base of the PR and between ab61aa9 and c4b0a2c.

📒 Files selected for processing (6)
  • .github/workflows/ci.yml
  • .github/workflows/release.yml
  • CONTRIBUTING.md
  • README.md
  • composer.json
  • phpstan.neon
📝 Walkthrough

Walkthrough

The repository is configured as a Composer HTTP package with CI, contribution policies, and documentation. It adds immutable request and response abstractions, URI and site helpers, content negotiation, HTTP method semantics, user-agent parsing, uploaded-file support, and initial PHPUnit coverage.

Changes

HTTP package foundation

Layer / File(s) Summary
Repository and package foundation
.gitattributes, .github/*, .gitignore, CHANGELOG.md, CODE_OF_CONDUCT.md, CONTRIBUTING.md, LICENSE, README.md, SECURITY.md, SUPPORT.md, composer.json, phpstan.neon, phpunit.xml
Package metadata, Composer scripts, PHPStan/PHPUnit configuration, CI automation, repository policies, documentation, and MIT licensing are added or updated.
Request construction and immutable access
src/Request.php, src/Contracts/RequestAware.php, tests/RequestTest.php
Request gains factories, input and file accessors, URL and negotiation helpers, path matching, deep cloning, immutable mutators, and tests for core request behavior.
HTTP value objects and protocol helpers
src/Method.php, src/Negotiate.php, src/Uri.php, src/SiteUri.php, src/UserAgent.php, src/UploadedFile.php, tests/MethodTest.php, tests/UriTest.php
HTTP methods, content negotiation, immutable URIs, site URL generation, user-agent parsing, and FPM/Swoole-compatible uploaded files are introduced with method and URI tests.
Response construction and transport output
src/Concerns/ManagesResponse.php, src/Response.php
Named response constructors, immutable header and cookie operations, callback streaming, file responses, body materialization, transport inspection, and chunked output are added.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Request
  participant Negotiate
  participant Response

  Client->>Request: Send HTTP method, headers, query, and body
  Request->>Negotiate: Select supported media type or language
  Negotiate-->>Request: Return negotiated value
  Request->>Response: Build response from request handling
  Response-->>Client: Send headers and body or stream content
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 41.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: extracting and open-sourcing the PhpServicePlatform HTTP layer.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch master

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 10

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/ISSUE_TEMPLATE/bug_report.yml:
- Around line 8-9: Update the Security Policy link in the issue form’s
introductory text to use the repository-root path ../../SECURITY.md (or an
absolute repository URL), while preserving the existing warning text.

In @.github/workflows/ci.yml:
- Around line 3-7: Harden the pull-request workflow by configuring
actions/checkout with token persistence disabled and declaring least-privilege
workflow permissions, using read-only contents access unless a narrower
permission set is already sufficient. Update the workflow-level settings near
the on trigger; do not grant write permissions or expose the checkout token to
Composer/PHP execution.

In `@composer.json`:
- Around line 32-35: Align the PHP baseline with Symfony 8.1 by updating
composer.json and README.md to require PHP 8.4.1 or newer, and remove PHP
8.2/8.3 from the CI matrix. Alternatively, retain the PHP 8.2 baseline by
pinning symfony/http-foundation and symfony/mime to compatible versions; apply
the same chosen baseline consistently in both affected files.

In `@src/Request.php`:
- Around line 243-247: Update the all() docblock to accurately describe the
values returned by its current implementation, removing the “(+ files)” claim
unless the method is also changed to merge $this->files.
- Line 28: Update the InputBag declarations in Request, including the json
property docblock and the return types around the related accessor methods, to
use InputBag<string|int|float|bool|null>. Apply the same generic annotation
consistently to all three bare InputBag references.

In `@src/Response.php`:
- Around line 150-153: Update Response::back to validate the supplied referer
before passing it to redirect: accept only same-origin or relative paths, and
use the trusted fallback for external, malformed, null, or empty values. Ensure
attacker-controlled Referer content is never reflected into the Location header.
- Around line 315-333: Update Response::streamTo to handle isFile() responses
before the existing body() fallback: open the file at the stored file path, read
it in fixed-size chunks, and pass each non-empty chunk to $writer without
loading the entire file into memory. Preserve the current streamCallback
behavior and existing body() handling for non-file responses, including
appropriate resource cleanup.
- Around line 35-41: Update Response::json to encode data with
JSON_THROW_ON_ERROR instead of falling back to '{}', allowing JsonException to
propagate for malformed UTF-8 or unsupported values; handle that exception at
the application boundary according to the existing error-mapping behavior.
- Around line 161-169: Update Response::jsonp to validate the callback before
embedding it in the JavaScript response, permitting only safe
identifier/member-expression syntax and rejecting invalid or attacker-controlled
values before sprintf is called. Preserve the existing JSON encoding, status,
and response headers for valid callbacks.

In `@src/UserAgent.php`:
- Around line 67-73: Update the match handling in the browser-detection loop to
access the guaranteed first capture group directly, removing the dead
null-coalescing fallback from the $m[1] assignment while preserving the existing
browser and version behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: caa87333-851a-4b7c-ba59-ebd831fed3bf

📥 Commits

Reviewing files that changed from the base of the PR and between ef09a72 and ab61aa9.

📒 Files selected for processing (32)
  • .gitattributes
  • .github/CODEOWNERS
  • .github/ISSUE_TEMPLATE/bug_report.yml
  • .github/ISSUE_TEMPLATE/config.yml
  • .github/ISSUE_TEMPLATE/feature_request.yml
  • .github/PULL_REQUEST_TEMPLATE.md
  • .github/dependabot.yml
  • .github/workflows/ci.yml
  • .gitignore
  • CHANGELOG.md
  • CODE_OF_CONDUCT.md
  • CONTRIBUTING.md
  • LICENSE
  • README.md
  • SECURITY.md
  • SUPPORT.md
  • composer.json
  • phpstan.neon
  • phpunit.xml
  • src/Concerns/ManagesResponse.php
  • src/Contracts/RequestAware.php
  • src/Method.php
  • src/Negotiate.php
  • src/Request.php
  • src/Response.php
  • src/SiteUri.php
  • src/UploadedFile.php
  • src/Uri.php
  • src/UserAgent.php
  • tests/MethodTest.php
  • tests/RequestTest.php
  • tests/UriTest.php

Comment thread .github/ISSUE_TEMPLATE/bug_report.yml
Comment thread .github/workflows/ci.yml
Comment thread composer.json Outdated
Comment thread src/Request.php
Comment thread src/Request.php
Comment thread src/Response.php
Comment thread src/Response.php
Comment thread src/Response.php
Comment thread src/Response.php
Comment thread src/UserAgent.php
@hakeemRash
hakeemRash merged commit 9111774 into main Jul 22, 2026
4 checks passed
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