承接 mrdulal/laravel-wp-connector 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mrdulal/laravel-wp-connector

Composer 安装命令:

composer require mrdulal/laravel-wp-connector

包简介

A Laravel package for WordPress database integration with Filament admin management

README 文档

README

Laravel WordPress Connector

Latest Version on Packagist Total Downloads License PHP Version Laravel Version Filament Version Build Status Code Coverage Code Quality PHPStan

A comprehensive Laravel package that seamlessly integrates WordPress database functionality into Laravel applications with full Filament admin panel support.

Features

  • 🔗 WordPress Database Integration: Connect to WordPress database with Eloquent models
  • 🎨 Filament Admin Panel: Complete admin interface for managing WordPress content
  • 📊 Dashboard Widgets: Real-time statistics and recent content widgets
  • 🔍 Advanced Queries: Easy-to-use facade for complex WordPress queries
  • 🏷️ Relationships: Full relationship mapping between WordPress entities
  • ⚙️ Configurable: Publishable config with database connection options

Installation

  1. Install the package via Composer:
composer require mrdulal/laravel-wp-connector
  1. Publish the configuration file:
php artisan vendor:publish --tag=wp-connector-config
  1. Configure your WordPress database connection in config/wordpress.php:
return [
    'enabled' => true,
    'host' => env('WP_DB_HOST', '127.0.0.1'),
    'port' => env('WP_DB_PORT', '3306'),
    'database' => env('WP_DB_DATABASE', 'wordpress'),
    'username' => env('WP_DB_USERNAME', 'root'),
    'password' => env('WP_DB_PASSWORD', ''),
    'prefix' => env('WP_DB_PREFIX', 'wp_'),
];
  1. Add your WordPress database credentials to your .env file:
WP_CONNECTOR_ENABLED=true
WP_DB_HOST=127.0.0.1
WP_DB_PORT=3306
WP_DB_DATABASE=wordpress
WP_DB_USERNAME=root
WP_DB_PASSWORD=your_password
WP_DB_PREFIX=wp_

Usage

Basic Queries

use MrDulal\WpConnector\Facades\Wp;

// Get recent published posts with authors
$posts = Wp::posts()->published()->with('author')->latest()->take(5)->get();

// Get posts by category
$categoryPosts = Wp::postsByCategory('Technology');

// Get posts by tag
$tagPosts = Wp::postsByTag('Laravel');

// Get user count
$userCount = Wp::userCount();

// Get comment count
$commentCount = Wp::commentCount();

Working with Models

use MrDulal\WpConnector\Models\WpPost;
use MrDulal\WpConnector\Models\WpUser;
use MrDulal\WpConnector\Models\WpComment;

// Get a post with its author and comments
$post = WpPost::with(['author', 'comments'])->find(1);

// Get user's posts
$user = WpUser::find(1);
$userPosts = $user->posts()->published()->get();

// Get post comments
$post = WpPost::find(1);
$comments = $post->comments()->approved()->get();

// Get post terms (categories/tags)
$post = WpPost::find(1);
$categories = $post->terms()->categories()->get();
$tags = $post->terms()->tags()->get();

Meta Data

// Get post meta
$post = WpPost::find(1);
$featuredImage = $post->getMeta('_thumbnail_id');
$customField = $post->getMeta('custom_field', 'default_value');

// Set post meta
$post->setMeta('custom_field', 'custom_value');

// Get user meta
$user = WpUser::find(1);
$firstName = $user->getMeta('first_name');
$lastName = $user->getMeta('last_name');

WordPress Options

use MrDulal\WpConnector\Facades\Wp;

// Get WordPress options
$siteName = Wp::option('blogname');
$siteDescription = Wp::option('blogdescription');

// Set WordPress options
Wp::setOption('custom_option', 'custom_value');

Filament Admin Panel

The package includes complete Filament resources for managing WordPress content:

  • Users: Manage WordPress users with full CRUD operations
  • Posts: Create, edit, and manage WordPress posts and pages
  • Comments: Moderate and manage comments
  • Terms: Manage categories, tags, and custom taxonomies

Dashboard Widgets

  • Recent Posts Widget: Shows latest published posts
  • User Count Widget: Displays user statistics
  • Comment Count Widget: Shows comment statistics

Configuration

Database Connection

The package automatically sets up a WordPress database connection. You can customize the connection settings in the config file.

Filament Configuration

'filament' => [
    'navigation_group' => 'WordPress',
    'navigation_sort' => 1,
    'enable_widgets' => true,
],

Models

WpUser

  • Primary key: ID
  • Relationships: posts(), comments(), meta()
  • Scopes: published()

WpPost

  • Primary key: ID
  • Relationships: author(), comments(), terms(), meta()
  • Scopes: published(), type(), byAuthor()

WpComment

  • Primary key: comment_ID
  • Relationships: post(), user(), parent(), children(), meta()
  • Scopes: approved(), byPost()

WpTerm

  • Primary key: term_id
  • Relationships: posts(), taxonomy(), meta()
  • Scopes: categories(), tags()

Advanced Usage

Custom Queries

// Get posts with specific meta
$posts = Wp::posts()
    ->whereHas('meta', function ($query) {
        $query->where('meta_key', 'featured')
              ->where('meta_value', '1');
    })
    ->published()
    ->get();

// Get users with specific capabilities
$admins = Wp::users()
    ->whereHas('meta', function ($query) {
        $query->where('meta_key', 'wp_capabilities')
              ->where('meta_value', 'like', '%administrator%');
    })
    ->get();

Relationship Loading

// Eager load relationships
$posts = Wp::posts()
    ->with(['author', 'comments', 'terms'])
    ->published()
    ->get();

// Load specific relationships
$post = WpPost::with(['author.meta', 'comments.user'])->find(1);

Requirements

  • PHP 8.1+
  • Laravel 10.0+
  • Filament 3.0+
  • WordPress database

License

This package is open-sourced software licensed under the MIT license.

Contributing

Please see CONTRIBUTING.md for details.

Changelog

Please see CHANGELOG.md for more information on what has changed recently.

Credits

mrdulal/laravel-wp-connector 适用场景与选型建议

mrdulal/laravel-wp-connector 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 5, 最近一次更新时间为 2025 年 10 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 mrdulal/laravel-wp-connector 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mrdulal/laravel-wp-connector 我们能提供哪些服务?
定制开发 / 二次开发

基于 mrdulal/laravel-wp-connector 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-05