PHPackages                             kekke88/phpdantic - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. kekke88/phpdantic

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

kekke88/phpdantic
=================

Data validation using PHP type hints.

v1.0.0(2y ago)33Apache-2.0PHPPHP ^7.4||^8.0CI passing

Since Nov 19Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/Kekke88/phpdantic)[ Packagist](https://packagist.org/packages/kekke88/phpdantic)[ RSS](/packages/kekke88-phpdantic/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Phpdantic
=========

[](#phpdantic)

Data validation using PHP type hints.

Installation
============

[](#installation)

Composer
--------

[](#composer)

Inside your project enter the following;

```
composer require kekke88/phpdantic

```

Introduction
============

[](#introduction)

Have you ever seen code such as;

```
...
$json = $client->request('GET', '/user/1');
$user = json_decode($json);

if(!isset($user->name) || !is_string($user->name)) {
    die("Name does not exist");
}
...

```

Where you'd have to go the API docs back and forth and guess what the user object contains? This library intends to solve this the easy way, by using validation against a data model and assigning values to the model so that you can use your IDE´s features for your objects.

Example
=======

[](#example)

```
