core

PHP Simple Fast & Secure

View on GitHub

PSFS Core Contracts

Status: verified Version: 1.1
Audience: framework users and contributors

This document defines the behavioural contracts of the core PSFS runtime. The goal is to make it explicit which behaviours are stable and safe to rely on, and which areas are considered internal implementation details.

Anything explicitly documented here is treated as public API.
Breaking these contracts requires a major version bump.


1. Core runtime

1.1 Dispatcher

Responsibility

The Dispatcher is the main entry point of PSFS:

Contract

Non-contractual / internal


1.2 Request

Responsibility

Request is a representation of the incoming HTTP request PSFS is handling:

Contract

Non-contractual / internal


1.3 Response

Responsibility

Response encapsulates everything PSFS will send back to the client:

Contract

Non-contractual / internal


1.4 Router

Responsibility

Router is responsible for:

Contract

Non-contractual / internal


1.5 Security

Responsibility

Security centralises security-related behaviour for PSFS:

Contract

Non-contractual / internal


1.6 Cache

Responsibility

Cache provides a framework-level cache abstraction used by PSFS itself and optionally by user code:

Contract

Non-contractual / internal


2. Helpers

Helpers are thin, convenient facades over the core runtime. They are intended for application code, but they should not introduce additional global state.

2.1 I18nHelper

Responsibility

Contract


2.2 SecurityHelper

Responsibility

Contract


2.3 AuthHelper

Responsibility

Contract


2.4 RouterHelper

Responsibility

Contract


3. Service layer

PSFS encourages encapsulating business logic into “services”. The framework provides base classes that define how services interact with the runtime.

3.1 Base Service

Responsibility

Contract


3.2 CurlService

Responsibility

Contract


3.3 SimpleService

Responsibility

Contract


4. Exceptions

PSFS defines a set of framework-specific exceptions under src/base/exception.

Responsibility

Contract

(TBD) Exception catalogue

This section will be filled with a table of all exception classes, including:

  • Exception class name
  • Category (routing / security / config / internal error / …)
  • Typical throwers (Dispatcher, Router, Security, etc.)
  • Expected HTTP behaviour (status code) when unhandled

5. API layer

The API layer is built on top of the components described above.

Responsibility

High-level contract

(TBD) API contract catalogue

To be completed progressively:

  • List important API endpoints (especially ones exposed to external integrators).
  • Document their request/response contracts.
  • Explicitly tag which ones are stable and versioned.

6. Compatibility guidelines

When evolving PSFS, changes should be evaluated according to this document:

Contributors are expected to update this CONTRACTS.md file when making changes that affect these contracts.