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
Static Entity

Static Entity Laravel Package

byscripts/static-entity

Static Entity provides model/entity-like behavior backed by static arrays. Define constants and a dataset to access rich objects without a database—ideal for enums, reference lists, and small lookup tables in PHP/Laravel apps.

View on GitHub
Deep Wiki
Context7

Provide some kind of static entities

Frequently asked questions about Static Entity
How do I use this package for country or state dropdown lists in Laravel?
Extend `AbstractStaticEntity` and define constants for each entry (e.g., `US`, `CA`). Use `getDataSet()` to map constants to structured arrays. Access entries via `WebBrowser::find(1)` or iterate with `WebBrowser::all()`. It mimics Eloquent but uses static arrays instead of a database.
Is this package compatible with Laravel 10+ and PHP 8.1+?
No, the last release was in 2018, so it likely lacks support for Laravel 10+ features like enums, model macros, or first-party caching. Test thoroughly in a fresh Laravel 10.x project to identify breaking changes, especially with service providers or Eloquent integrations.
Can I dynamically update static data without editing PHP files?
The package doesn’t natively support dynamic updates. You’d need to manually edit the `getDataSet()` array or build an admin panel to regenerate the class. For real-time updates, consider alternatives like `spatie/laravel-static-tables` or database-backed seeders with caching.
How does this compare to Laravel’s built-in `config()` or database seeders?
Unlike `config()`, this package provides object-oriented access (e.g., `Country::find('US')->getName()`) and mimics Eloquent methods. Seeders require a database, while this uses static arrays—ideal for read-heavy, rarely modified data. However, seeders offer easier updates and version control.
Will this work in a Laravel microservice architecture?
It’s designed for monolithic Laravel apps, not microservices. If you need API-driven static data, consider exposing it via Laravel Sanctum/Passport or using a standalone API service. The package lacks built-in API endpoints or containerization support.
How do I cache static entities to improve performance?
The package doesn’t include built-in caching. Manually cache results using Laravel’s cache system (e.g., `Cache::remember()`) or implement a service provider to auto-cache entities. For invalidation, use cache tags or events when data changes.
Are there alternatives with better Laravel 10+ support?
Yes. For static data, try `spatie/laravel-static-tables` (database-backed with caching) or `laravel-shift/database-entities` (hybrid static/database). For enums, Laravel’s native `enum` feature (Laravel 10+) or `benmatsons/laravel-enum` are lighter alternatives.
How do I test this package in my Laravel app?
Mock the `AbstractStaticEntity` class in unit tests to verify behavior. Test edge cases like invalid IDs, circular references, and data updates. Since it’s unmaintained, write integration tests to ensure compatibility with your Laravel version and dependencies.
Can I use this for multi-language/localized static data?
No, the package doesn’t support localization. For multi-language static data, use Laravel’s localization features (e.g., `Lang::get()`) or a database-backed solution like seeders with translated fields.
What’s the fallback if this package breaks or becomes unsustainable?
Replace it with a database seeder, `spatie/laravel-static-tables`, or hardcoded arrays/config. Since the package mimics Eloquent, migrating to a custom static class or Laravel’s native solutions (e.g., `config()`, `enum`) is straightforward.
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.
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log