承接 jdwx/param 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jdwx/param

最新稳定版本:v1.1.29

Composer 安装命令:

composer require jdwx/param

包简介

A simple PHP module for parsing values from strings with type safety.

README 文档

README

A simple PHP module for parsing values from strings with type safety.

This is useful in a number of contexts:

  • Parsing HTTP request arguments.
  • Parsing database values returned as string-or-NULL.
  • Parsing values from configuration files.
  • Parsing values from command-line arguments.

Installation

You can require it directly with Composer:

composer require jdwx/param

Or download the source from GitHub: https://github.com/jdwx/param.git

Requirements

This library requires PHP 8.1 or later. It does not work with earlier versions. (Uses readonly properties.) It requires the mbstring extension and uses the Ds data structure extension or polyfill but has no other external dependencies.

Usage

<?php

declare( strict_types = 1 );

require 'vendor/autoload.php';

use JDWX\Param\Parameter;

$st = readline( "Enter an integer: " );
if ( $st === false ) {
    echo "No input\n";
    exit( 1 );
}

try {
    $p = new Parameter( $st );
    $i = $p->asInt();
    echo "You entered: {$i}\n";
} catch ( TypeError $e ) {
    echo "ERROR: ", $e->getMessage(), "\n";
}

Experimental documentation is available at: https://jdwx.github.io/param/namespaces/jdwx-param.html

Stability

This library is stable and has been used in production code. It is not expected to change in ways that break existing code. Additional parsing methods may be added in the future, but existing methods should not be changed in a way that breaks existing code without at least a minor version update.

History

This library has been in use for several years in production code. It was originally part of a larger library that was broken up into smaller pieces in 2023 and has been released as a standalone library in 2024.

统计信息

  • 总下载量: 466
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-04