PHPackages                             viames/pair\_boilerplate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. viames/pair\_boilerplate

ActiveProject[Framework](/categories/framework)

viames/pair\_boilerplate
========================

Skeleton project based on Pair PHP framework

3.0.0(2mo ago)212MITPHPCI passing

Since Jan 17Pushed 3w ago3 watchersCompare

[ Source](https://github.com/viames/pair_boilerplate)[ Packagist](https://packagist.org/packages/viames/pair_boilerplate)[ Docs](https://github.com/viames/pair_boilerplate)[ RSS](/packages/viames-pair-boilerplate/feed)WikiDiscussions main Synced yesterday

READMEChangelog (10)Dependencies (3)Versions (29)Used By (0)

Pair boilerplate
================

[](#pair-boilerplate)

Skeleton project for building applications with [Pair PHP Framework](https://github.com/viames/pair).

[![Latest Stable Version](https://camo.githubusercontent.com/dba320ea07e8cf5bbc5c4f0579f255d417641127879ee65b209c257921af6d91/68747470733a2f2f706f7365722e707567782e6f72672f7669616d65732f706169725f626f696c6572706c6174652f762f737461626c65)](https://packagist.org/packages/viames/pair_boilerplate)[![Total Downloads](https://camo.githubusercontent.com/371a4a91d6027708cabec703a486932ea3af7e1a73d06bfa88b36d0882e894b2/68747470733a2f2f706f7365722e707567782e6f72672f7669616d65732f706169725f626f696c6572706c6174652f646f776e6c6f616473)](https://packagist.org/packages/viames/pair_boilerplate)[![Latest Unstable Version](https://camo.githubusercontent.com/17db8c4f1756519b397fd048abde303974c34eadc7e4934a69fbfe37bf58f6de/68747470733a2f2f706f7365722e707567782e6f72672f7669616d65732f706169725f626f696c6572706c6174652f762f756e737461626c65)](https://packagist.org/packages/viames/pair_boilerplate)[![License](https://camo.githubusercontent.com/20c6b883410bf33cdedebde80c428ea3cd690c1b70444bd864bbbc759fe2ee37/68747470733a2f2f706f7365722e707567782e6f72672f7669616d65732f706169725f626f696c6572706c6174652f6c6963656e7365)](https://packagist.org/packages/viames/pair_boilerplate)[![composer.lock](https://camo.githubusercontent.com/13eac4b2ed6d537f445bf3d68b2c17186e8319a04221c213a0ffd81164e83a2b/68747470733a2f2f706f7365722e707567782e6f72672f7669616d65732f706169725f626f696c6572706c6174652f636f6d706f7365726c6f636b)](https://packagist.org/packages/viames/pair_boilerplate)

This repository provides a ready-to-install baseline for small and medium PHP applications such as CRM tools, internal portals and web back offices. It includes authentication, users and groups, ACL management, localization, a REST API entry point, OAuth2 support, migrations and a generator for CRUD modules.

The project targets the Pair 4 alpha development line. Bundled modules are aligned with the explicit Pair 4 web path based on `Pair\Web\Controller`, `PageResponse` and typed `*PageState` classes. Legacy implicit `View` variables are being replaced by explicit page state objects, and the `crafter` module generates Pair 4-style controller, state and layout files for new modules.

Requirements
------------

[](#requirements)

- PHP 8.4.1 or newer.
- MySQL 8.0 or newer.
- Apache with `mod_rewrite` enabled.
- Composer.
- PHP extensions:
    - `curl`
    - `fileinfo`
    - `intl`
    - `json`
    - `mbstring`
    - `pdo`
    - `pdo_mysql`

Installation
------------

[](#installation)

Create a new project with Composer:

```
composer create-project viames/pair_boilerplate my_project_name
```

Open the project URL in the browser:

```
http://localhost/my_project_name

```

The installer starts automatically when the root URL is opened for the first time. It checks the environment, creates or updates the database, imports the Pair 4 baseline schema and seed data, writes the `.env` file, creates the first administrator account and removes itself after a successful installation.

After installation, open the application URL and log in with the generated administrator credentials shown by the installer. Change the generated password after the first login.

Apache Configuration
--------------------

[](#apache-configuration)

Enable Apache `mod_rewrite`:

```
sudo a2enmod rewrite
```

Make sure the project directory allows `.htaccess` rules. A typical configuration is:

```

    Options Indexes FollowSymLinks
    AllowOverride All

```

MySQL Configuration
-------------------

[](#mysql-configuration)

Pair applications should use `utf8mb4` and `utf8mb4_unicode_ci`. A typical MySQL configuration is:

```
[mysql]
default-character-set=utf8mb4

[mysqld]
collation-server = utf8mb4_unicode_ci
init-connect='SET NAMES utf8mb4'
character-set-server = utf8mb4
sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
```

Verify that:

- the database uses charset `utf8mb4` and collation `utf8mb4_unicode_ci`;
- the database user can create, read, write, update and delete data in the project database;
- the database server time is correct, for example with `SELECT NOW();`.

Configuration
-------------

[](#configuration)

Runtime configuration is stored in `.env`. Fresh installations generate it automatically from the installer. For existing installations, use `.env.example` as the reference structure.

Important Pair options include:

- `PAIR_AUDIT_ALL`
- `PAIR_SINGLE_SESSION`
- `PAIR_AUTH_BY_EMAIL`
- `PAIR_LOGGER_EMAIL_RECIPIENTS`
- `PAIR_LOGGER_EMAIL_THRESHOLD`
- `PAIR_LOGGER_TELEGRAM_CHAT_IDS`
- `PAIR_LOGGER_TELEGRAM_THRESHOLD`
- `PAIR_MOBILE_ACCESS_TOKEN_LIFETIME`
- `PAIR_MOBILE_REFRESH_TOKEN_LIFETIME`

The generated `.env` also contains cryptographic keys. Keep those values private and do not commit real production secrets.

Updates and Migrations
----------------------

[](#updates-and-migrations)

Install or update dependencies from the project root:

```
composer install
composer update
```

Composer runs `php migrate-cli.php` after install and update. The migration runner applies Pair vendor migrations first and application migrations immediately after.

Application migrations live in `/migrations` and should use the `YYYYMMDD_description.sql` naming convention. Treat migration files as append-only after they have been applied to an environment.

When checking legacy code against the Pair 4 migration helper, run:

```
composer run upgrade-to-v4 -- --dry-run
```

The expected dry-run result for the current codebase is:

```
Changed files: none
Warnings: none

```

Development Commands
--------------------

[](#development-commands)

Run the test suite:

```
composer test
```

Run the Pair CLI wrapper:

```
composer run pair -- list
```

Generate a module:

```
composer run pair -- make:module orders
```

Generate a CRUD module from a database table:

```
composer run pair -- make:crud order --table=orders --fields=id,customer_id,total_amount
```

Cron
----

[](#cron)

Schedule `cronjob.php` every minute on Linux:

```
* * * * * /var/www/html/cronjob.php
```

Adjust the path to match the project location.

Self-Test
---------

[](#self-test)

After installation:

1. Log in as an administrator.
2. Open the `Self test` module.
3. Confirm that every check is green.
4. Fix every reported red `X` before treating the environment as ready.

Folder Structure
----------------

[](#folder-structure)

```
/classes
/installer
    /sql
        schema.sql
        seed.sql
/migrations
/modules
    /module1
        /assets
        /classes
        controller.php
        model.php
        /layouts
            default.php
/public
    /assets
    /css
    /img
    /js
    /plugins
    .htaccess
    index.php
/temp
/templates
    /template1
        default.php
        login.php
        404.php
/translations
    en-GB.ini
    it-IT.ini
/vendor
/widgets
.env
.env.example
.gitignore
.htaccess
composer.json
composer.lock
cronjob.php
migrate-cli.php
README.md
routes.php

```

The `/installer/sql` folder contains the fresh-install baseline split into schema and seed files. The `/migrations` folder contains append-only upgrade migrations.

Architecture
------------

[](#architecture)

Pair modules are organized around Controller, Model, state classes and layouts.

### Controller

[](#controller)

Controllers should contain routing, access checks and request orchestration. Keep business rules, SQL details and presentation markup out of controllers.

In Pair 4-style modules, controllers return explicit responses such as `PageResponse` and pass typed state objects to layouts.

### Model

[](#model)

Models should contain business logic, queries and form handling that is shared by multiple pages of the same module. Keep request routing and presentation markup out of models.

### Page State and Layouts

[](#page-state-and-layouts)

Typed `*PageState` classes carry the data needed by a page. Layout files render HTML and should stay presentation-focused, with only simple conditions, loops and escaped output.

Do not add new legacy `View` classes for Pair 4 modules. Prefer typed state classes and explicit responses.

Crafter Module
--------------

[](#crafter-module)

The `crafter` module scans database tables that are not yet associated with a module and generates Pair module code for CRUD workflows.

For best results:

- use InnoDB tables;
- define primary keys clearly;
- type every field correctly;
- define foreign key relationships where they express real data ownership or lookup behavior;
- review generated code before shipping it.

Coding Conventions
------------------

[](#coding-conventions)

Use CamelCase for PHP classes and variables:

```
$mySpecialClass = new MySpecialClass();
```

Use uppercase constants separated by underscores:

```
define('CUSTOMIZED_CONSTANT', TRUE);
```

Prefer clear multiline conditions:

```
if (is_null($var)) {
    $var = 0;
} else {
    $var = 1;
}
```

Use short inline conditions only when readability stays high:

```
$var = is_null($var) ? 0 : 1;
```

Use tabs for indentation in `.php` files, configured at 4 spaces visually.

In inline PHP templates, avoid abbreviated PHP tags and use `print` consistently with the existing codebase:

```

```

Comment every PHP and JavaScript function. Add comments for non-trivial blocks when the intent is not immediately obvious:

```
/**
 * Render the setup form with the current installer state.
 */
public function printSetupPage(): void {
    // ...
}
```

Public Text
-----------

[](#public-text)

When adding user-facing HTML, wiki content, documentation, notifications or error messages, check grammar before finishing the change. For Italian text, verify accents and wording carefully.

Contributing
------------

[](#contributing)

Pull requests are welcome. Keep changes focused, include tests when behavior changes and update documentation when commands, requirements, API behavior or installation steps change.

License
-------

[](#license)

MIT

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance91

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~116 days

Recently: every ~108 days

Total

27

Last Release

74d ago

Major Versions

1.6.0 → 3.0.0-alpha2025-02-11

2.0.0 → 3.0.0-beta2025-11-19

3.0.0 → 4.0.0-alpha2026-04-22

PHP version history (3 changes)1.0.0PHP &gt;=5.6

1.5.0PHP &gt;=7

1.5.3PHP ^7

### Community

Maintainers

![](https://www.gravatar.com/avatar/c8172f2606a13967b8fbb94b0a9885139a8d314c4ce98e9501f06a1d82a394ed?d=identicon)[Viames](/maintainers/Viames)

---

Top Contributors

[![viames](https://avatars.githubusercontent.com/u/15028802?v=4)](https://github.com/viames "viames (145 commits)")

---

Tags

composercrudmvcmysqlpairphpskeletonphpframeworkrouterpaginationmultilingualoauth2active-recordREST APIpairplugin-system

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/viames-pair-boilerplate/health.svg)

```
[![Health](https://phpackages.com/badges/viames-pair-boilerplate/health.svg)](https://phpackages.com/packages/viames-pair-boilerplate)
```

###  Alternatives

[viames/pair

Lightweight PHP framework for fast server-rendered web applications with MVC routing, ActiveRecord ORM and API tooling

103.5k2](/packages/viames-pair)[leafs/leaf

Elegant PHP for modern developers

1.3k48.6k11](/packages/leafs-leaf)[scrawler/router

An Fully Automatic RESTful PHP Router.

562.2k3](/packages/scrawler-router)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
