wenprise/eloquent
Lightweight extensions for Laravel Eloquent that add helpful query and model utilities, cleaner builder macros, and convenience helpers to speed up common database tasks. Designed to drop into existing apps with minimal setup and familiar Eloquent syntax.
Model, Migration, or ServiceProvider patterns).$wpdb with Eloquent’s query builder, enabling fluent queries (e.g., User::where('status', 'active')->get()).WP_Post, WP_User, etc., as Eloquent models with relationships, accessors, and observers.wp-content/plugins/ structure may need adaptation).add_filter('the_title', ...) system. Potential for naming collisions (e.g., created_at vs. WordPress’s post_date).WP_Object_Cache) may conflict with Laravel’s cache drivers. Middleware or custom cache adapters may be needed.wp_users) could cause issues.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Schema Conflicts | High | Validate migrations against WordPress core tables. Use database prefixes (e.g., wp_ vs. custom tables). |
| Performance Overhead | Medium | Benchmark Eloquent queries vs. $wpdb for critical paths. Consider query caching. |
| Dependency Bloat | Medium | Isolate Laravel dependencies to a single plugin or theme. Use autoloading optimizations. |
| Hook Collisions | Low | Prefix Eloquent-related hooks (e.g., eloquent_model_loaded) and document conflicts. |
| Long-Term Maintenance | High | Monitor WordPress core updates for breaking changes (e.g., database schema evolutions). |
Why Eloquent?
Database Strategy
$wpdb usage, or only extend it for specific tables?Post::where('post_type', 'product')->get())Team Adoption
$wpdb) collaborate with Laravel developers?Deployment Risks
Alternatives
Phase 1: Proof of Concept
wp_users) and replace $wpdb queries with Eloquent models.Phase 2: Incremental Adoption
class WP_User extends \WP_User {
use \Wenprise\Eloquent\Model;
}
Phase 3: Full Integration
$wpdb usage in custom code with Eloquent.add_action('plugins_loaded', function() {
$app = new \Illuminate\Foundation\Application();
$app->register(\Wenprise\Eloquent\ServiceProvider::class);
});
.env for database credentials) alongside WordPress’s wp-config.php.wp_options serialization, postmeta handling) may require custom Eloquent model logic.Prerequisites:
composer require illuminate/support illuminate/database
config/database.php to match WordPress’s wp-config.php settings.Critical Order:
plugins_loaded hook.$wpdb calls after verifying Eloquent queries work identically.Rollback Plan:
$wpdb if Eloquent fails.Dependency Management:
vendor/ directory during deployment.Update Risks:
wp_posts).illuminate/database could introduce breaking changes.composer.json.Debugging:
php artisan tinker) for interactive debugging.error_log.Learning Curve:
$wpdb to Eloquent (e.g., get_results() → Model::all()).Community Resources:
How can I help you explore Laravel packages today?