Repository navigation
Diagnostics and doctor
Unreleased core work toward 0.10.0 Cirrus. This page describes source 3ac444e0b892d7d1d0406a908cd873bd0b063594, tracked by #20 and PR #55. These APIs are absent from tagged 0.9.1. They require no Cloudflare account token, database, scheduler or network probe and install no public diagnostic route.
use Moztopia\Cloudflare\Facades\Cloudflare;
use Moztopia\Cloudflare\HeaderStatus\HeaderStatus;
$report = Cloudflare::diagnostics();
$report->trusted;
$report->ingress;
$report->configurationIssues;
if ($report->header('CF-Region') === HeaderStatus::Missing) {
// This accepted request did not supply the region header.
}Typed dependency injection uses the same service. The returned Diagnostics snapshot is final/readonly, independently copies its header/issue arrays and exposes no supplied header, visitor, proxy or credential values. Names are case-insensitive; querying an unsupported/unassessed name throws InvalidArgumentException. Manually constructed snapshots are application-supplied data.
HeaderStatus has four backed values:
-
Untrusted(untrusted): ingress was not accepted, so the header was not assessed. This does not imply it is present. -
Missing(missing): accepted ingress supplied no such header. -
Rejected(rejected): the header was supplied but failed the same validation used by the normal parser, including empty/duplicate/unsafe values. -
Parsed(parsed): the parser accepted the supplied value. A parsedXX/T1country marker is still a marker, not a known country.
Supported names are CF-IPCountry, CF-IPContinent, CF-Region, CF-Region-Code, CF-IPCity, CF-Timezone, CF-IPLatitude, CF-IPLongitude, CF-Metro-Code, CF-Connecting-IP, CF-Ray and CF-Visitor. Missing data cannot establish which Cloudflare product or setting is enabled. The report makes no control-plane lookup.
IngressStatus distinguishes Trusted, Untrusted, NoRequest, InvalidRequest, MissingPeer, InvalidPeer, InvalidConfiguration and NoTrustedProxies. The trusted boolean is true only for Trusted, matching normal request-context acceptance. It describes the configured immediate-peer policy, not cryptographic Cloudflare identity or the truth of arbitrary client-supplied data. Trusted ingress still requires controlled routing and header provenance; Laravel forwarded-header trust alone is insufficient. No request binding produces unknown visitor/context values rather than inventing an HTTP request.
Reports retain the assessment that created them; later request/configuration/container changes do not update an old report. Use diagnostics in internal tests or authorized support tooling. The package does not add an HTTP route, emit raw metadata to logs or change the application's request, trusted proxies, locale or timezone.
Run in a bootable consuming Laravel application:
php artisan moztopia-cloudflare:doctor
php artisan moztopia-cloudflare:doctor --jsonThe collision-resistant command name is intentional. It inspects the effective moztopia-cloudflare configuration or its compatible cloudflare fallback, reports only the configured-entry count and issue codes, then runs the real parser in four explicit isolated request fixtures: trusted, missing, malformed and untrusted. The active application's request/configuration/container binding is preserved.
These are configuration and synthetic checks. No live browser request has been observed, and no HTTP/DNS probe is made. Passing samples do not validate the site's actual Cloudflare ingress, settings, account plan or product entitlement. Configuration that prevents Laravel from booting must be fixed before an Artisan command can run.
Exit code 0 means the synthetic checks passed and no unsafe/invalid configuration was found. Empty default trust is safe/unknown and prints setup guidance. Exit code 1 reports invalid/unsafe configuration or an unexpected synthetic-check failure. The command never rewrites trust settings or enables products.
Configuration issue codes are:
-
empty_trust: no configured accepted peers; normal request reads remain unknown until deliberately configured. -
invalid_trust_list: the effective setting is not an array. -
invalid_trust_entry: an entry is not a supported IP/CIDR value. -
unrestricted_trust: a zero-prefix CIDR does not define a controlled ingress perimeter and must be replaced.
An invalid entry can coexist with a valid matching entry; the report retains actual reader behavior while identifying the configuration problem. No configured entry is printed. Verify that the controlled ingress overwrites or removes client-supplied supported headers before accepting its peer; an address match alone does not prove header provenance.
--json returns schemaVersion: 1, scope: configuration_and_synthetic_samples, liveRequestObserved: false, redacted configuration data, syntheticChecksPassed and four diagnostic samples. configuration.source names the effective namespace, configuredEntries counts all supplied list entries, and issues contains machine codes. Backed enum values serialize as their stable status strings. There are no raw header/proxy/visitor values, and status codes do not change with the human language.
Human command text uses Laravel's moztopia-cloudflare::doctor translation namespace, with English, Thai and Arabic catalogs. The host controls its locale, enabled languages and fallback; the package does not select or enable them. Partial application overrides use the native location lang/vendor/moztopia-cloudflare/<locale>/doctor.php. Package defaults remain available for other keys. JSON keys/statuses remain language-independent.
Tests cover all four header states, country markers, rejected duplicates/unsafe values, malformed configuration, canonical/legacy precedence, redaction, no active browser observation, input-reference detachment, readonly reports, request/container changes, host-language overrides, direct catalog completeness/placeholder parity, stable JSON and preservation of the active application state. The actual example invokes the packaged command in both human and JSON modes. Package catalogs are included in both the source archive and the fresh example image; language changes select package and example CI checks.
The local six-way PHP/Laravel matrix passes 143 tests / 547 assertions per combination; package Pint passes 54 files. The PHP 8.5.13 example passes 41 tests / 720 assertions and Pint for 26 files. Strict Composer and actionlint checks pass. Actual GitHub run/publication evidence is recorded on Unreleased core. These checks do not replace the separate expanded worker/trust or controlled live-ingress gates.
Maintained by-dolly.
Released API reference: 0.9.0 — Cirrus. Future capabilities are marked on the Roadmap.
Repository · Project website · Apache-2.0
Maintained by-dolly.

Moztopia Cloudflare
- Home
- Getting started
- Trusted ingress
- Visitor and request context
- Diagnostics and doctor
- Blade and testing
- Example website
- Development and verification
- Branding
- SDK contract
- Roadmap
- Unreleased core work
- Release gates
- Optional credential-free additions
- V2 discovery
- Planning decisions
- Ecosystem review
- Ecosystem inventory
Maintained by-dolly.