Skip to content
Viames Marino edited this page Nov 28, 2026 · 59 revisions

Pair framework documentation

Pair is a compact PHP framework for server-rendered applications. It combines a classic MVC flow, an ActiveRecord-oriented ORM, API tooling, and lightweight frontend utilities without forcing a heavy build chain.

The current stable release is Pair 4.4.4. This wiki tracks Pair v4 on the default main branch; unreleased changes may appear before the next tag. Pair v4 is the current stable line; the v3 branch and 3.x tags remain available for applications on the previous maintenance line.

The most useful way to read it is to distinguish between:

  • class reference pages, which explain the main methods with examples and keep secondary methods concise
  • workflow and integration pages, which focus on end-to-end patterns such as API modules, PWA features, or external service integrations

Install and configure

Pair requires PHP 8.4.1 or later within PHP 8, with PHP 8.4 and 8.5 as the target runtimes, and the Composer extensions curl, intl, json, mbstring, PDO, and pdo_mysql. Optional features may require additional extensions or packages; check the relevant integration page before using them.

The default database driver requires MySQL 8.0 or later. Pair 4.1.12 adds MySQL 26.10/utf8mb4 coverage documented in Database; compare that page with the release installed in your application.

Install Pair 4.4.4 or a later compatible Pair 4 release:

composer require "viames/pair:^4.4.4"

For a ready-to-run application, use the starter project. Configure the environment and database before running the bootstrap: see Configuration file, htaccess, and Env.

The stable starter 4.0.0 requires Pair ^4.1.12 and provides a single installation command:

composer create-project viames/pair_boilerplate my-project

The fresh installer requires a new or empty database; existing application databases are updated through migrations. The new app receives its own composer.lock, which should be committed in the application's repository.

New modules should use Pair\Web\Controller and explicit responses. Pair\Core\Controller, Model, and View remain migration bridges; see Upgrade to v4.

Pair uses two distinct extension mechanisms:

Development and tests

Pair includes a lightweight PHPUnit suite for framework-level checks.

Typical local workflow:

  • composer install
  • composer test

For real-server compatibility, run the separate composer test:mysql suite after provisioning the isolated schema described in the MySQL integration guide. CI targets PHP 8.4/8.5 and MySQL 8.0, 8.4 and 26.10. This suite does not use an application's .env and does not replace application-specific verification.

Notes:

  • the suite focuses on isolated framework behavior, so many tests do not require a full Pair application bootstrap
  • vendor/ is a local install artifact and should not be committed to the Pair repository
  • when you change observable framework behavior, update the relevant wiki page together with the code

Code generation

Pair v4 includes a small bin/pair generator for explicit web modules, API modules, and CRUD skeletons. Start from Generator when creating new Pair v4 files.

Recommended learning paths

1) Bootstrap and request lifecycle

Read index.php -> Application -> Router -> Controller -> Input -> UploadedFile -> PageResponse -> FragmentResponse -> ResponseInterface.

2) Build a CRUD module with explicit responses

Read Generator -> Controller -> PageResponse -> FragmentResponse -> ReadModel -> ActiveRecord -> Query -> Form.

3) Build a JSON API

Read API -> ApiController -> Request -> RequestData -> ApiResponse -> JsonResponse -> CrudController -> ReadModel -> Idempotency.

4) Authentication, session, and ACL

Read User -> Session -> ApiToken -> AuthAttemptLimiter -> SocialAuth -> Acl -> Rule -> OAuth2Token.

5) Native mobile API clients

Read Mobile auth app setup, Mobile iOS stack, and Mobile Android stack before wiring native apps directly to Pair authentication endpoints.

6) External services and integrations

Start from Integrations for optional SDK requirements and adapter registration, then use the relevant service reference below.

Navigation tree

Reading tips

  • When a page is about a class, prefer it for method-by-method reference.
  • When a page is about a feature area or hub such as API or Integrations, expect overview material, architecture notes, recipes, and cross-links rather than a full method inventory.
  • Use composer show viames/pair to identify the version installed in an application. Compare its source with the matching Git tag. Pair 4.4.4 source is the current stable baseline. This wiki follows main.

Clone this wiki locally