Weave Code
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
Laravel Dao

Laravel Dao Laravel Package

edstevo/laravel-dao

Laravel DAO layer for models, inspired by repository pattern. Adds caching, broadcast events, validation, and model/DAO generators to centralize data access and keep controllers flexible across Laravel apps.

View on GitHub
Deep Wiki
Context7

Laravel Dao Package with built in caching of data objects, validation and model generation

Frequently asked questions about Laravel Dao
Is edstevo/laravel-dao compatible with Laravel 10+? If not, what are the risks?
No, this package was last updated for Laravel 5.x and lacks support for modern Laravel versions. Using it risks API deprecation issues (e.g., cache drivers, events) and missing features like Eloquent Accessors/Mutators. You’d need to fork and backport updates, which could introduce bugs or compatibility gaps.
How does the caching layer work, and can I customize cache keys or TTL?
The package integrates with Laravel’s cache drivers (Redis, Memcached, etc.) but doesn’t provide built-in cache key management or TTL configuration. You’ll need to manually define keys and invalidation logic, which could lead to stale data or cache stampedes if not handled carefully.
Can I use this package for a simple CRUD app, or is it overkill?
This package adds complexity with repositories, caching, and event broadcasting, which may be unnecessary for simple CRUD apps. If your project is lightweight, Eloquent alone or Laravel’s API Resources might suffice without the overhead of a DAO layer.
Does laravel-dao support broadcasting events for real-time updates?
Yes, it broadcasts Laravel events (e.g., model created/updated/deleted) and integrates with Laravel Echo/Pusher for real-time features. However, broadcasting requires additional setup (e.g., queue workers, Pusher credentials) and may not be needed for non-real-time apps.
How do I generate DAOs for my Eloquent models? Are there CLI tools included?
The package includes model/DAO generators to scaffold repositories automatically. You’d typically run a command (e.g., `php artisan dao:generate`) to create a DAO class for a model, which handles CRUD operations, caching, and validation. Check the README for exact syntax.
Will this package work with Laravel Scout for search functionality?
No, this package predates Laravel Scout and doesn’t include support for search-as-you-type or full-text search features. If you need Scout, you’ll have to implement it separately alongside the DAO layer.
How do I test repositories in PHPUnit? Can I mock DAOs easily?
Yes, repositories can be mocked in unit tests like any Laravel service. Define clear interfaces or contracts for your DAOs to ensure testability. Use Laravel’s mocking tools (e.g., `Mockery`) to isolate repository logic from Eloquent queries.
Are there alternatives to laravel-dao for Laravel 10+ with better maintenance?
For modern Laravel, consider packages like **spatie/laravel-repository-pattern**, **nWidart/laravel-modules**, or **laravel-eloquent-repository**. These are actively maintained, support newer Laravel versions, and offer similar repository abstractions without legacy risks.
How does validation work in laravel-dao? Can I reuse existing Laravel validation rules?
The package supports validation at the repository level, allowing you to define rules (e.g., using Laravel’s `Validator` facade) within the DAO. You can reuse existing validation logic from Form Requests or models, but validation is enforced during DAO operations, not at the controller level.
What’s the best way to migrate from Eloquent directly to using DAOs?
Start by identifying high-traffic or complex models (e.g., User, Product) and wrap their Eloquent logic in DAOs incrementally. Use the generator to scaffold repositories, then refactor controllers/services to delegate data access to the DAO layer. Avoid big-bang rewrites—migrate one model at a time.
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.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle