Search by

attributes-php / strictify-ext

matapatos

Pydantic-inspired PHP library for validating data via type hints at lightning speed ⚡️

Package info

github.com/Attributes-PHP/strictify-ext

Language:C

Type:php-ext

Ext name:ext-attributes-strictify

pkg:composer/attributes-php/strictify-ext

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

v1.0.0 2026-11-26 19:57 UTC

README

strictify logo

GitHub Actions Workflow Status (main) Code Coverage Latest Version Static Badge Software License

Strictify Extension is a Pydantic-inspired PHP library for validating data via type hints at lightning speed ⚡️ It shares its API, behavior and documentation with strictify, the pure-PHP Composer flavor of the same library: same models, same functions — the extension just runs them at native speed.

Prerequisites

  • PHP 8.2 or later

We aim to support versions that haven't reached their end-of-life.

How it works?

<?php

use function Attributes\Strictify\validate;
use Attributes\Strictify\BaseModel;

class User extends BaseModel
{
    public float|int $age;
    public ?DateTime $birthday;
}

$rawData = [
    'age' => 30,
    'birthday' => '1994-01-01T09:00:00+00:00',
];
$user = validate($rawData, new User());

var_dump($user->age);      // int(30)
var_dump($user->birthday); // object(DateTime) { ["date"] => string(26) "1994-01-01 09:00:00.000000", (...) }

Need to call a function?

<?php

use function Attributes\Strictify\call;

function myFunction(User $user) {
    var_dump($user->age);      // int(30)
    var_dump($user->birthday); // object(DateTime) { ["date"] => string(26) "1994-01-01 09:00:00.000000", (...) }
}

call("myFunction", $rawData);

Installation

pie install attributes-php/strictify-ext

For the widest compatibility — including shared hosting and managed platforms where PHP extensions cannot be installed — use the pure-PHP flavor instead, which requires no code changes:

composer require attributes-php/strictify

Documentation

Full documentation lives at strictify.attributes-php.com:

  • Quickstart — first model and first validation in under a minute
  • Guides — validating payloads, nested models, aliases, error messages, sensitive data, call(), toDict()
  • Reference — validate(), toDict(), call(), ModelConfigs, constraints, exceptions, API
  • Benchmarks, FAQ and Changelog
  • For LLMs and agents: llms.txt indexes every page (each also served as Markdown), and llms-full.txt has the full docs in one file

Strictify Extension was created by André Gil and is open-sourced software licensed under the MIT license.