Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Php Types Laravel Package

tdn/php-types

A small PHP utility for working with types: safely cast values, validate data against expected types, and normalize scalars, arrays and objects. Lightweight and framework-agnostic, it drops easily into Laravel or any Composer project.

View on GitHub
Deep Wiki
Context7

tdn/php-types brings pragmatic, strongly-typed building blocks to modern PHP. It provides lightweight value objects, typed collections, and safe casting helpers, letting you replace loose arrays and scalar juggling with expressive, self-validating types—without pulling in a heavy dependency.

  • Value objects with built-in validation and immutability
  • Typed collections that enforce element types while staying iterable
  • Safe casting from arrays, scalars, and JSON payloads
  • Laravel-friendly integration with plain-PHP fallbacks
  • Zero-config, framework-agnostic design
Frequently asked questions about Php Types
What is tdn/php-types used for?
It boxes PHP scalars into immutable value objects such as Int, String, Float, Bool, and Arr with validation and fluent accessors. It is intended for primitive-obsession reduction and clearer domain code, not as a full Laravel integration. It provides no service provider, facade, config, or Eloquent casts.
Does tdn/php-types work with Laravel 10 or 11?
There is no framework coupling, so there is nothing to register in config/app.php or bootstrap/providers.php. That also means no published Laravel casts, validation rules, request hydration, or API resource support. Every Laravel integration point must be hand-written, and compatibility with Laravel 10 or 11 on PHP 8.1 to 8.3 is unverified and likely broken.
How do I install tdn/php-types with Composer?
It is Composer-installable with PSR-4 autoloading and has no transitive dependency tree to audit. With only a single 2015 tag and no published SemVer history, constraint resolution will likely require dev-master pinning. Do not add it to composer.json if the license is unresolved; vendor-by-copy selectively after legal review.
Is tdn/php-types compatible with PHP 8.1, 8.2, or 8.3?
Compatibility is unverified and plausibly broken. The classes are named String, Int, Float, and Bool, which are reserved words in PHP 7+ and fatal in PHP 8.x. That is a go/no-go on the artifact itself. No PHP-version fixes exist because the project is archived.
Does tdn/php-types have a license I can use commercially?
GitHub cannot detect a declared license, reporting NOASSERTION, so commercial distribution or inclusion in a proprietary product is a legal unknown. There is no explicit OSI license to review. Obtain counsel sign-off before copying any code. If the license does not clear, reimplement the pattern from scratch.
Is tdn/php-types actively maintained?
No. There is a single 2015 tag, no CI badge, no coverage report, and no documentation site. The repository is archived with no maintainer, so there is no security response path or CVE triage. You become the maintainer by default.
Can I use tdn/php-types value objects with Eloquent casts or JSON serialization?
Boxed scalars break json_encode, Eloquent attribute casting, session and queue payloads, and Blade prop expectations unless you write converters. No published casts or factories are included. You must hand-write every conversion layer and implement Stringable or JsonSerializable yourself.
What are alternatives to tdn/php-types for type safety in Laravel?
Native PHP 7+ scalar types, PHP 8.1 readonly properties, and native enums cover about 90% of the value with zero dependency risk. For specific needs, consider webmozart/assert, ramsey/uuid, brick/money, or native DTOs. Writing two or three wrapper classes in-house is likely under one day each.
How do I test or validate data with tdn/php-types?
The library provides validation inside its immutable value objects, but there are no Laravel validation rules, factories, or testing utilities included. With no CI badge, coverage report, or documentation, integration knowledge must be reverse-engineered from source. You will need to write your own tests and converters.
Should I install tdn/php-types in a production Laravel app?
Generally no. It is poor as a dependency because it has no Laravel touchpoints, unresolved licensing, archived maintenance, PHP 8 fatal risks, and serialization friction. Treat it as a pattern reference and copy only the two or three wrapper classes you genuinely need into your own namespace. Rewrite them for PHP 8.2 with final readonly typed properties and Stringable or JsonSerializable implementations.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo