Download the PHP package onaonbir/oo-metas without Composer
On this page you can find all versions of the php package onaonbir/oo-metas. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download onaonbir/oo-metas
More information about onaonbir/oo-metas
Files in onaonbir/oo-metas
Package oo-metas
Short Description Flexible and extensible metadata management system for Laravel models with caching, dot notation, connected models, and type-safe value objects.
License MIT
Homepage https://onaonbir.com
Informations about the package oo-metas
๐ง OOMetas โ Flexible Metadata Manager for Laravel
OOMetas is a powerful, refactored polymorphic metadata management system for Laravel.
It provides a clean architecture with repository pattern, service layer, caching, and extensive features for managing dynamic key-value data on any model.
โจ Key Features
- ๐๏ธ Clean Architecture: Repository pattern, Service layer, Contracts
- โก Performance: Built-in caching layer with configurable TTL
- ๐ง Flexible: Supports connected models and nested keys (dot notation)
- ๐ก๏ธ Type Safety: Strict typing with PHP 8.3+ and Value Objects
- ๐ฆ Batch Operations: Efficient bulk operations for better performance
- ๐ฏ Exception Handling: Proper error handling with custom exceptions
- ๐ Validation: Built-in validation for keys and values
- ๐งช Testable: Fully testable with dependency injection
๐ง Installation
-
Install the package:
-
Publish and run migrations:
- Publish configuration (optional):
๐๏ธ Architecture Overview
๐ Usage Guide
1. ๐งฉ Using the Trait (Recommended)
Add the HasMetas trait to any model:
Basic Operations
Batch Operations
Numeric Operations
Special Operations
Array Operations
Type-Safe Getters
2. ๐ Connected Models
Connect metadata to relationships between models:
3. ๐ฏ Using the Facade
4. ๐๏ธ Direct Service Usage
โ๏ธ Configuration
Cache Configuration
Validation Configuration
Performance Configuration
๐ก๏ธ Error Handling
The package provides specific exceptions for better error handling:
๐งช Testing
The refactored architecture makes testing much easier:
๐ Performance Considerations
- Use Caching: Enable caching for frequently accessed metadata
- Batch Operations: Use
setMany/getManyfor multiple operations - Indexed Queries: The package automatically indexes queries by model and key
- Connection Scoping: Use connected models to scope metadata efficiently
๐ Migration from Previous Versions
The new version is backward compatible, but to take advantage of new features:
- Update your code to use the trait methods instead of direct
OOMetas::calls - Enable caching in configuration
- Use batch operations where possible
- Consider using Value Objects for better type safety
๐ Advanced Usage
Custom Repository Implementation
Custom Value Objects
๐ ๏ธ Contributing
- Fork the repository
- Create a feature branch
- Write tests for your changes
- Ensure all tests pass
- Submit a pull request
๐ License
MIT ยฉ OnaOnbir
๐ฏ Example Use Cases
- User Preferences: Theme, language, notification settings
- Feature Flags: Per-user or per-model feature toggles
- Dynamic Forms: Store form responses dynamically
- Analytics: Store usage statistics and metrics
- Workflow States: Track process states and configurations
- Multi-tenant Data: Scope data per tenant/organization
- Audit Trails: Store metadata about changes and actions
License
MIT - See LICENSE for details.
Built by OnaOnbir.