Download the PHP package nejcc/php-datatypes without Composer

On this page you can find all versions of the php package nejcc/php-datatypes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-datatypes

PHP Datatypes: Strict, Safe, and Flexible Data Handling for PHP

Latest Version on Packagist Total Downloads GitHub Actions

Quality Gate Status Security Rating Maintainability Rating Vulnerabilities Bugs Duplicated Lines (%) Lines of Code


Overview

PHP Datatypes is a robust library that brings strict, safe, and expressive data type handling to PHP. It provides a comprehensive set of scalar and composite types, enabling you to:

Whether you are building business-critical applications, APIs, or data processing pipelines, PHP Datatypes helps you write safer and more predictable PHP code.

Key Benefits

Impact on Modern PHP Development

PHP Datatypes is designed to address the challenges of modern PHP development, where data integrity and type safety are paramount. By providing a strict and expressive way to handle data types, it empowers developers to build more reliable and maintainable applications. Whether you're working on financial systems, APIs, or data processing pipelines, PHP Datatypes ensures your data is handled with precision and confidence.

Features

Installation

Install via Composer:

Requirements

Note: This library leverages PHP 8.4 features for improved performance and cleaner syntax. For older PHP versions, please use version 1.x.

PHP 8.4 Features

Modern Array Functions

The library leverages PHP 8.4's new array functions for better performance and cleaner code.

Before (PHP 8.3):

After (PHP 8.4):

Attribute-Based Validation

Use PHP attributes for declarative validation:

Available attributes:

Performance Improvements

PHP 8.4 array functions provide 15-30% performance improvement over manual loops in validation-heavy operations:

Why Use PHP Datatypes?

Why Developers Love PHP Datatypes

Usage Examples

Laravel Example

Scalar Types

Integers

Floats

Arithmetic Operations

Migration from Getter Methods

Legacy Syntax (v1.x):

Modern Syntax (v2.x - Recommended):

Note: Direct property access will be available in v3.0.0 with property hooks.

Algebraic Data Types

Option Type for Nullable Values

Result Type for Error Handling

Array Validation with PHP 8.4

Modern validation using array functions:

Laravel Integration

Validation Rules

Eloquent Casts

Roadmap

Development Tools

Testing

Run the test suite with:

Static Analysis

Run PHPStan for static analysis:

Mutation Testing

Run Infection for mutation testing:

Performance Benchmarks

Run performance benchmarks to compare native PHP vs php-datatypes, including PHP 8.4 optimizations:

Results show 15-30% improvement in validation operations with PHP 8.4 array functions.

Code Style

Run Laravel Pint for code formatting:

Changelog

Please see CHANGELOG for details on recent changes.

Migration Guide

From v1.x to v2.x

Key Changes:

Breaking Changes:

Recommended Actions:

  1. Update to PHP 8.4
  2. Run your test suite
  3. Update composer.json: "nejcc/php-datatypes": "^2.0"
  4. Review CHANGELOG.md for detailed changes

Preparing for v3.x

Future v3.0 will introduce property hooks, allowing direct property access:

Both syntaxes will work in v2.x with deprecation notices.

Contributing

Contributions are welcome! Please see CONTRIBUTING for guidelines.

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Real-Life Examples

Financial Application

In a financial application, precision and type safety are critical. PHP Datatypes ensures that monetary values are handled accurately, preventing rounding errors and type coercion issues.

API Development

When building APIs, data validation and type safety are essential. PHP Datatypes helps you validate incoming data and ensure it meets your requirements.

Data Processing Pipeline

In data processing pipelines, ensuring data integrity is crucial. PHP Datatypes helps you maintain data consistency and prevent errors.

Advanced Usage

Custom Types

PHP Datatypes allows you to define your own custom types, enabling you to encapsulate complex data structures and validation logic.

Validation Rules

You can define custom validation rules to ensure your data meets specific requirements.

Serialization

PHP Datatypes supports easy serialization and deserialization of data structures.

PHP 8.4 Array Operations

Leverage built-in array functions for cleaner code:


All versions of php-datatypes with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-bcmath Version *
ext-ctype Version *
ext-zlib Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nejcc/php-datatypes contains the following files

Loading the files please wait ...