xdevor/type
Composer 安装命令:
composer require xdevor/type
包简介
A Laravel package which object type collection powered by Laravel's validation components.
README 文档
README
In this package we've introduced a new type package that focuses on validating object types.
This package not only allows you to validate basic data types but also supports complex object structures. Using Laravel's fluent validation syntax, you can define the expected properties of an object to ensure their types and existence.
Installation
Require this package with composer:
composer require xdevor/type
Usage
- ❌ Without object type
function increase(int $count) { if ($count < 1) { throw new InvalidArgumentException('Receive invalid argument'); } return $this->value + $count; }
- ✅ With object type
use Xdevor\Type\Numbers\PositiveInt; function increase(PositiveInt $count) { return $this->value + $count->value(); }
Features
Supports
- PositiveInt: Positive integer
- NegativeInt: Negative integer
Todo
- NonZeroInt: Non-zero integer
- PositiveFloat: Positive floating-point number
- NegativeFloat: Negative floating-point number
- NonZeroFloat: Non-zero floating-point number
- NonEmptyString: Non-empty string
- EmailAddress: Email address
- Url: URL
- PhoneNumber: Phone number
- Date: Date
- DateTime: Date and time
- Uuid: Universally Unique Identifier (UUID)
- IPv4Address: IPv4 address
- IPv6Address: IPv6 address
- HexColorCode: Hexadecimal color code
- AlphanumericString: Alphanumeric string
- Json: JSON string
- ArrayOfType: Array of a specific type
- CustomEnum: Custom enumeration type
- CreditCardNumber: Credit card number
- SocialSecurityNumber: Social Security number
- LatitudeLongitude: Latitude and longitude coordinates
- CurrencyAmount: Currency amount
- Percentage: Percentage value
- FileSize: File size
- TimeInterval: Time interval
- ISBN: International Standard Book Number (ISBN)
- MACAddress: MAC address
- IBAN: International Bank Account Number (IBAN)
- Password: Password with specific constraints
- PostalCode: Postal code
- CreditScore: Credit score
- FahrenheitTemperature: Temperature in Fahrenheit
- CelsiusTemperature: Temperature in Celsius
- BinaryData: Binary data
- Gender: Gender (Male/Female/Other)
- Latitude: Latitude coordinate
- Longitude: Longitude coordinate
- ISBN13: ISBN-13
- IMEI: International Mobile Equipment Identity (IMEI)
- CreditCardExpirationDate: Credit card expiration date
- VATNumber: Value Added Tax (VAT) number
- HexadecimalNumber: Hexadecimal number
- BooleanString: Boolean represented as a string
- RomanNumeral: Roman numeral
- PassportNumber: Passport number
- MIMEType: Multipurpose Internet Mail Extensions (MIME) type
- MACAddressOUI: MAC address Organizationally Unique Identifier (OUI)
- EAN13: International Article Number (EAN-13)
- EAN8: International Article Number (EAN-8)
- VehicleIdentificationNumber (VIN): VIN for vehicles
- ISSN: International Standard Serial Number (ISSN)
- UPC: Universal Product Code (UPC)
- GS1Barcode: GS1 Barcode
- MD5Hash: MD5 hash
- SHA1Hash: SHA-1 hash
- SHA256Hash: SHA-256 hash
- SHA512Hash: SHA-512 hash
- RGBColor: RGB color
- RGBAColor: RGBA color (with alpha channel)
- HSLColor: HSL color
- HSLAColor: HSLA color (with alpha channel)
- HTMLColorName: HTML color name
- Base64EncodedString: Base64-encoded string
- ISBN10: ISBN-10
- USStateAbbreviation: US state abbreviation
- CanadianPostalCode: Canadian postal code
- SocialMediaUsername: Social media username
- HexadecimalRGBColor: Hexadecimal RGB color
- AlphabeticalString: Alphabetical string
- MongoDBObjectId: MongoDB Object ID
- JWToken: JSON Web Token (JWT)
- UnixTimestamp: Unix timestamp
- YouTubeVideoId: YouTube video ID
- HexadecimalUUID: Hexadecimal UUID
- HTTPStatusCode: HTTP status code
- SemVer: Semantic versioning string
- EpochTime: Epoch time
- HexadecimalMACAddress: Hexadecimal MAC address
- GoogleAnalyticsTrackingId: Google Analytics tracking ID
- USZipCode: US ZIP code
- Slug: URL-friendly slug
- TwitterHandle: Twitter handle
- HexadecimalBinary: Hexadecimal binary data
- RandomGuid: Randomly generated GUID
- ICAOAirportCode: ICAO airport code
- HexadecimalHTMLColor: Hexadecimal HTML color code
- GitCommitHash: Git commit hash
- CustomMimeType: Custom MIME type
- GPSCoordinates: GPS coordinates
- AmericanExpressCardNumber: American Express credit card number
- MasterCardNumber: MasterCard credit card number
- VisaCardNumber: Visa credit card number
- DinersClubCardNumber: Diners Club credit card number
- DiscoverCardNumber: Discover credit card number
- JCBCardNumber: JCB credit card number
- DebitCardNumber: Debit card number
- WindowsFilePath: Windows file path
- UnixFilePath: Unix file path
- CurrencyCode: Represents the code of a currency (e.g., USD, EUR).
- CurrencyAmount: Represents the numerical value of an amount in a specific currency.
- ExchangeRate: Represents the exchange rate between two currencies.
- CryptocurrencyCode: Represents the code of a cryptocurrency (e.g., BTC, ETH).
- CryptocurrencyAmount: Represents the numerical value of an amount in a specific cryptocurrency.
- BitcoinAddress: Represents a Bitcoin wallet address.
- EthereumAddress: Represents an Ethereum wallet address.
- LitecoinAddress: Represents a Litecoin wallet address.
- RippleAddress: Represents a Ripple wallet address.
- MoneroAddress: Represents a Monero wallet address.
- StellarAddress: Represents a Stellar wallet address.
- EOSAddress: Represents an EOS wallet address.
- DashAddress: Represents a Dash wallet address.
- ZcashAddress: Represents a Zcash wallet address.
- USDCurrency: Represents the United States Dollar (USD).
- EuroCurrency: Represents the Euro (EUR).
- BritishPoundCurrency: Represents the British Pound (GBP).
- JapaneseYenCurrency: Represents the Japanese Yen (JPY).
- CanadianDollarCurrency: Represents the Canadian Dollar (CAD).
- AustralianDollarCurrency: Represents the Australian Dollar (AUD).
- SwissFrancCurrency: Represents the Swiss Franc (CHF).
- ChineseYuanCurrency: Represents the Chinese Yuan (CNY).
- IndianRupeeCurrency: Represents the Indian Rupee (INR).
- BrazilianRealCurrency: Represents the Brazilian Real (BRL).
- SouthAfricanRandCurrency: Represents the South African Rand (ZAR).
- SwedishKronaCurrency: Represents the Swedish Krona (SEK).
- NorwegianKroneCurrency: Represents the Norwegian Krone (NOK).
- SingaporeDollarCurrency: Represents the Singapore Dollar (SGD).
- NewZealandDollarCurrency: Represents the New Zealand Dollar (NZD).
- MexicanPesoCurrency: Represents the Mexican Peso (MXN).
Contributing
Please see CONTRIBUTING for details.
Code of Conduct
In order to ensure that the php community is welcoming to all, please review and abide by the Code of Conduct.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
License
This package is open-sourced software licensed under the MIT license.
xdevor/type 适用场景与选型建议
xdevor/type 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 11 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「validation」 「type」 「laravel」 「Value Object」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 xdevor/type 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 xdevor/type 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 xdevor/type 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A bundle providing fields for image upload with jquery upload and image cropping with jcrop for symfony2
A simple Symfony bundle that adds boolean form field type.
A PHP Abstract Enum Class
This package provides type-safe extension of the laravel collection, forcing a single type of object.
Compatibility layer for emulating enumerations in PHP < 8.1 and native enumerations in PHP >= 8.1
Provides Symfony param converters for mediagone/types-common package.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-11-11