jobmetric/typeify
Composer 安装命令:
composer require jobmetric/typeify
包简介
A flexible and extensible type system for managing structured data behaviors in Laravel applications.
README 文档
README
Typeify
Define Types. Attach Behavior. Scale Cleanly.
Typeify simplifies how you define and manage type registries in Laravel. Stop scattering type configs and ad-hoc flags across your codebase—define named types once, attach labels, descriptions, import/export flags, and custom options through a single fluent API. This is where structured type management meets developer-friendly simplicity: one base class, composable traits, and the Laravel container as the single source of truth.
Why Typeify?
One Registry Per Concern
Keep your type definitions normalized and queryable. Each subclass of BaseType is a single registry (e.g. post types, product types, taxonomy types). Define types with unique keys, attach parameters via fluent methods, and read them anywhere in the request lifecycle. No duplicated config arrays or scattered conditionals.
Composable Behavior with Traits
- Labels & Descriptions – Attach translatable label and description per type (
HasLabelType,HasDescriptionType). - Import / Export – Enable import or export per type with a single flag (
HasImportType,HasExportType). - Hierarchical & List Options – Mark types as hierarchical or control list UI (show description, remove filter, change status) via
HasHierarchicalTypeandHasListOptionType. - Driver Namespaces – Register custom driver classes per type with
HasDriverNamespaceType.
Add only the traits you need. Your type classes stay thin and consistent.
Laravel-Native Storage
All type data lives in the Laravel service container under the key returned by typeName(). The same definitions are available in controllers, APIs, admin panels, and CLI—no extra wiring, no custom globals. Use trans() for labels and descriptions so localization works out of the box.
What is a Type?
A type in Typeify is a named key (e.g. blog, product, page) inside a single registry—your subclass of BaseType. Each type holds a set of parameters: label, description, and any flags or options you attach via traits.
- Define – Call
define('key')to register a new type, then chain methods to set parameters. - Select – Call
type('key')to switch the current type and read or update its parameters. - Store – All data is stored in the Laravel container under
typeName(), so it is global and consistent for the request.
Consider a content system that needs post types (blog, news, page) and product types (physical, digital). With Typeify, you create a PostType and a ProductType registry, define each type with labels and descriptions, enable import/export or hierarchical where needed, and reuse the same definitions everywhere—in forms, tables, and API responses. The power lies not only in centralizing type config but in making it discoverable, translatable, and extensible through traits.
What Awaits You?
By adopting Typeify, you will:
- Reduce development time – Focus on domain types instead of config plumbing and duplicated arrays
- Write cleaner, more maintainable code – One registry per concern, fluent API, no scattered type checks
- Scale your type system effortlessly – Add traits and new types without breaking existing ones
- Stay Laravel-native – Service container,
trans()for labels/descriptions, and familiar patterns throughout - Empower consistency – Same type definitions everywhere: APIs, admin panels, and CLI
Quick Start
Install Typeify via Composer:
composer require jobmetric/typeify
Usage (Examples)
Create a type registry by extending BaseType and implementing typeName():
namespace App\Type; use JobMetric\Typeify\BaseType; class PostType extends BaseType { protected function typeName(): string { return 'post-type'; } }
Define types and attach parameters (labels, descriptions, flags):
$postType = new PostType(); $postType->define('blog') ->label('Blog Post') ->description('Posts for the blog section') ->hierarchical() ->import() ->export(); $postType->define('news') ->label('News') ->description('News articles');
Select a type and read its data:
$postType->type('blog'); $label = $postType->getLabel(); $description = $postType->getDescription(); $allParams = $postType->get(); $postType->ensureTypeExists('blog'); $availableTypes = $postType->getTypes();
Documentation
Ready to centralize your type system? Our comprehensive documentation is your gateway to mastering Typeify:
The documentation includes:
- Getting Started – Quick introduction and installation guide
- BaseType – Define, select, get/set parameters, container storage
- Traits – HasLabelType, HasDescriptionType, HasImportType, HasExportType, HasHierarchicalType, HasListOptionType, HasDriverNamespaceType
- Exceptions – TypeifyTypeNotFoundException, TypeifyTypeNotMatchException
- Integration – Using type registries in other packages and the Laravel ecosystem
- Real-World Examples – Post types, product types, and custom traits
Contributing
Thank you for participating in typeify. A contribution guide can be found here.
License
The typeify is open-sourced software licensed under the MIT license. See License File for more information.
jobmetric/typeify 适用场景与选型建议
jobmetric/typeify 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 07 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「package」 「type」 「laravel」 「type system」 「jobmetric」 「system type」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jobmetric/typeify 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jobmetric/typeify 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jobmetric/typeify 相关的其它包
同方向 / 同关键字的高下载量 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.
统计信息
- 总下载量: 20
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 21
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-25