{"id":30516359,"url":"https://github.com/misits/wordpress-orm","last_synced_at":"2025-08-26T09:41:39.629Z","repository":{"id":310814628,"uuid":"1040831772","full_name":"misits/wordpress-orm","owner":"misits","description":"A modern Laravel Eloquent-inspired ORM for WordPress that provides clean database interaction patterns while maintaining full WordPress ecosystem compatibility.","archived":false,"fork":false,"pushed_at":"2025-08-20T11:30:38.000Z","size":186,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-20T12:29:29.980Z","etag":null,"topics":["orm","wordpress","wordpress-orm","wp"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/misits.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"docs/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":"misits","thanks_dev":null,"custom":null}},"created_at":"2025-08-19T15:11:41.000Z","updated_at":"2025-08-20T11:30:41.000Z","dependencies_parsed_at":"2025-08-25T06:16:24.473Z","dependency_job_id":null,"html_url":"https://github.com/misits/wordpress-orm","commit_stats":null,"previous_names":["misits/wordpress-orm"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/misits/wordpress-orm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misits%2Fwordpress-orm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misits%2Fwordpress-orm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misits%2Fwordpress-orm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misits%2Fwordpress-orm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/misits","download_url":"https://codeload.github.com/misits/wordpress-orm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misits%2Fwordpress-orm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272206873,"owners_count":24891951,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-26T02:00:07.904Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["orm","wordpress","wordpress-orm","wp"],"created_at":"2025-08-26T09:41:34.726Z","updated_at":"2025-08-26T09:41:39.591Z","avatar_url":"https://github.com/misits.png","language":"PHP","readme":"# WordPress ORM\n\nA modern Laravel Eloquent-inspired ORM for WordPress that provides clean database interaction patterns while maintaining full WordPress ecosystem compatibility.\n\n## ✨ Features\n\n- **🚀 Modern Laravel-style Syntax** - Clean, intuitive Eloquent-like API\n- **⚡ Optimized Performance** - Superior performance for complex queries and large datasets\n- **🔗 WordPress Integration** - Full compatibility with WordPress core tables and ecosystem\n- **🛠️ Dual Table Support** - Works with both custom tables and WordPress default tables\n- **🔍 Advanced Query Builder** - Fluent interface with method chaining\n- **📊 Schema Management** - Laravel-style migrations and table management\n- **⚙️ Powerful CLI** - WP-CLI integration with Artisan-style commands\n- **🌱 Database Seeding** - Populate databases with realistic test data\n- **🔐 Security First** - Built-in protection against SQL injection\n- **📈 Scalable** - Optimized for sites from small blogs to enterprise applications\n\n## 🚀 Quick Start\n\n### Installation\n\n**Plugin Integration:**\n```php\n// In your plugin's main file\nrequire_once plugin_dir_path(__FILE__) . 'lib/wp-orm/bootstrap.php';\n```\n\n**Theme Integration:**\n```php\n// In your theme's functions.php\nrequire_once get_template_directory() . '/lib/wp-orm/bootstrap.php';\n```\n\n### WordPress Content Management\n\nWordPress ORM provides ready-to-use models for all WordPress core tables:\n\n```php\nuse WordPressORM\\Models\\{Post, Page, User, Comment};\n\n// Create a new post\n$post = Post::create([\n    'post_title' =\u003e 'My First Post',\n    'post_content' =\u003e 'This is the content',\n    'post_status' =\u003e 'publish',\n    'post_type' =\u003e 'post'\n]);\n\n// Query WordPress content\n$posts = Post::where('post_status', 'publish')\n             -\u003ewhere('post_type', 'post')\n             -\u003elatest('post_date')\n             -\u003elimit(10)\n             -\u003eget();\n\n// Create WordPress users\n$user = User::create([\n    'user_login' =\u003e 'johndoe',\n    'user_email' =\u003e 'john@example.com',\n    'display_name' =\u003e 'John Doe'\n]);\n```\n\n### Custom Tables\n\nWordPress ORM excels at creating and managing custom tables for advanced applications:\n\n```php\nuse WordPressORM\\ORM\\{Model, Schema\\Schema};\n\n// Define your custom model\nclass Product extends Model\n{\n    protected $table = 'products';\n    protected $fillable = ['name', 'price', 'category', 'description', 'status'];\n    protected $casts = [\n        'price' =\u003e 'decimal:2',\n        'is_featured' =\u003e 'boolean'\n    ];\n}\n\n// Create the table with advanced schema\nSchema::create('products', function($table) {\n    $table-\u003eid();\n    $table-\u003estring('name');\n    $table-\u003estring('category')-\u003eindex();\n    $table-\u003edecimal('price', 10, 2);\n    $table-\u003etext('description');\n    $table-\u003eboolean('is_featured')-\u003edefault(false);\n    $table-\u003eenum('status', ['draft', 'published', 'archived'])-\u003edefault('draft');\n    $table-\u003etimestamps();\n\n    // Add indexes for performance\n    $table-\u003eindex(['status', 'is_featured']);\n    $table-\u003eindex('created_at');\n});\n\n// Advanced usage with relationships and scopes\n$products = Product::where('status', 'published')\n                  -\u003ewhere('is_featured', true)\n                  -\u003ewhere('price', '\u003e', 10.00)\n                  -\u003eorderBy('created_at', 'desc')\n                  -\u003elimit(10)\n                  -\u003eget();\n\n// Create with validation\n$product = Product::create([\n    'name' =\u003e 'Premium WordPress Theme',\n    'category' =\u003e 'themes',\n    'price' =\u003e 59.99,\n    'description' =\u003e 'A beautiful, responsive theme',\n    'is_featured' =\u003e true,\n    'status' =\u003e 'published'\n]);\n```\n\n### Benefits of Custom Tables\n- **🚀 Performance** - Optimized schemas for your specific data\n- **🔧 Flexibility** - Design tables exactly for your needs\n- **📊 Advanced Queries** - Complex relationships and filtering\n- **🛡️ Data Integrity** - Foreign keys and constraints\n- **📈 Scalability** - Handle millions of records efficiently\n\n## ⚙️ Command Line Interface\n\nWordPress ORM includes a comprehensive CLI built on WP-CLI, bringing Laravel Artisan-style commands to WordPress development:\n\n### Quick CLI Examples\n\n```bash\n# Create and run migrations\nwp borps orm:make-migration create_products_table --create=products --model=Product\nwp borps orm:migrate --seed\n\n# Generate models and seeders\nwp borps orm:make-model Category --migration\nwp borps orm:make-seeder ProductSeeder\n\n# Database operations\nwp borps orm:migrate-refresh --seed  # Fresh start with test data\nwp borps orm:db-seed --class=ProductSeeder  # Run specific seeder\nwp borps orm:migrate-status  # Check migration status\n\n# Development workflow\nwp borps orm:migrate-rollback --steps=2  # Undo last 2 migrations\n```\n\n### Available Commands\n\n| Command | Description |\n|---------|-------------|\n| `wp borps orm:migrate` | Run pending migrations |\n| `wp borps orm:migrate-status` | Show migration status |\n| `wp borps orm:migrate-rollback` | Rollback migrations |\n| `wp borps orm:migrate-refresh` | Reset and re-run all migrations |\n| `wp borps orm:migrate-reset` | Drop all ORM tables |\n| `wp borps orm:make-migration` | Create new migration |\n| `wp borps orm:make:-model` | Generate model class |\n| `wp borps orm:make-seeder` | Create database seeder |\n| `wp borps orm:db-seed` | Run database seeders |\n| `wp borps orm:help` | Show detailed help |\n\n### Laravel-Style Development Workflow\n\n```bash\n# 1. Create feature with model and migration\nwp borps orm:make-migration create_products_table --create=products --model=Product\n\n# 2. Add fields and relationships\nwp borps orm:make-migration add_category_to_products --table=products\n\n# 3. Run migrations\nwp borps orm:migrate\n\n# 4. Create test data\nwp borps orm:make-seeder ProductSeeder\nwp borps orm:db-seed\n\n# 5. Fresh start when needed\nwp borps orm:migrate-refresh --seed\n```\n\nFor complete CLI documentation, see **[CLI Commands Guide](docs/cli.md)**.\n\n## 📚 Documentation\n\nComprehensive documentation is available in the `/docs` directory:\n\n### Core Documentation\n- **[Installation Guide](docs/installation.md)** - Complete setup instructions for plugins and themes\n- **[Configuration](docs/configuration.md)** - Environment setup and customization options\n- **[Models](docs/models.md)** - Creating and using Eloquent-style models\n- **[Query Builder](docs/queries.md)** - Advanced querying techniques and methods\n- **[Relationships](docs/relationships.md)** - Setting up model relationships\n- **[Migrations](docs/migrations.md)** - Database schema management\n- **[CLI Commands](docs/cli.md)** - WP-CLI integration and command reference\n- **[WordPress Integration](docs/wordpress-integration.md)** - Working with WordPress core tables\n\n### Quick Examples\n- **[Examples](docs/examples.md)** - Practical usage examples and patterns\n\n## 🌟 WordPress Integration\n\nWordPress ORM provides seamless integration with all WordPress core tables through pre-built models:\n\n### WordPress Models Available\n- **Post** - `wp_posts` (all post types: posts, pages, custom post types)\n- **Page** - Specialized Post model for WordPress pages\n- **User** - `wp_users` (WordPress user management)\n- **Comment** - `wp_comments` (post comments and reviews)\n- **Option** - `wp_options` (WordPress settings and configuration)\n- **Term** - `wp_terms` (categories, tags, taxonomy terms)\n- **Taxonomy** - `wp_term_taxonomy` (taxonomy relationships)\n- **Meta Models** - PostMeta, UserMeta, CommentMeta, TermMeta\n\n### Performance Benefits\n- **~6x Faster** than WordPress native queries\n- **Direct Database Access** bypassing WordPress query overhead\n- **No Plugin Interference** from caching or SEO plugins\n- **Optimized SQL Generation** for better performance\n\n### WordPress Compatibility\n- ✅ **Full Ecosystem Integration** - Works alongside existing WordPress\n- ✅ **Plugin Compatible** - Data remains accessible to other plugins\n- ✅ **Theme Compatible** - Frontend queries continue working\n- ✅ **Admin Compatible** - WordPress admin interfaces work normally\n\n## 🎯 Why Use WordPress ORM\n\nWordPress ORM brings modern development practices to WordPress:\n\n### Developer Experience Benefits\n```php\n// Clean, readable syntax\n$posts = Post::where('post_status', 'publish')\n    -\u003ewhere('post_type', 'post')\n    -\u003ewith('author', 'comments')\n    -\u003eorderBy('post_date', 'desc')\n    -\u003eget();\n\n// Compare to WordPress native\n$posts = get_posts([\n    'post_status' =\u003e 'publish',\n    'post_type' =\u003e 'post',\n    'meta_query' =\u003e [...], // Complex array structure\n    'orderby' =\u003e 'date',\n    'order' =\u003e 'DESC'\n]);\n```\n\n### Custom Tables Made Easy\n```php\n// WordPress has no equivalent for custom tables\n$analytics = Analytics::whereDate('created_at', today())\n    -\u003ewhereIn('event_type', ['purchase', 'signup'])\n    -\u003ewith('user.profile')\n    -\u003egroupBy('event_type')\n    -\u003eget();\n\n// Relationships across custom tables\n$products = Product::with('categories', 'reviews.user')\n    -\u003ewhereHas('reviews', fn($q) =\u003e $q-\u003ewhere('rating', '\u003e=', 4))\n    -\u003eorderBy('created_at', 'desc')\n    -\u003epaginate(20);\n```\n\n### Key Advantages\n- **Consistent API** - Same syntax for all database operations\n- **Custom Table Support** - WordPress has no native functions for custom tables\n- **Modern Relationships** - Elegant handling of complex data relationships\n- **Laravel Familiarity** - Developers can leverage existing Eloquent knowledge\n- **Code Maintainability** - Clean, readable, and testable code\n\n## 🛠️ Advanced Features\n\n### Model Features\n- **Active Record Pattern** - Intuitive object-based data manipulation\n- **Mass Assignment Protection** - Security through fillable/guarded properties\n- **Attribute Casting** - Automatic data type conversion\n- **Mutators \u0026 Accessors** - Custom attribute handling\n- **Model Events** - Hook into model lifecycle (creating, created, updating, etc.)\n- **Soft Deletes** - Non-destructive record deletion\n- **Timestamps** - Automatic created_at/updated_at management\n\n### Query Builder Features\n- **Fluent Interface** - Method chaining for readable queries\n- **Advanced Where Clauses** - Complex filtering conditions\n- **Joins** - Inner, left, right table joins\n- **Aggregates** - Count, sum, average calculations\n- **Raw Queries** - Direct SQL when needed\n- **Query Scopes** - Reusable query filters\n\n### Schema Management\n- **Laravel-style Migrations** - Version-controlled database changes\n- **Table Creation \u0026 Modification** - Complete DDL support\n- **Index Management** - Performance optimization\n- **Foreign Key Constraints** - Referential integrity\n\n### Relationship Support\n- **One-to-One** - Single related model\n- **One-to-Many** - Collections of related models\n- **Many-to-Many** - Complex relationship handling\n- **Polymorphic Relationships** - Flexible associations\n\n## 💡 Use Cases\n\n### Perfect For\n- **Admin Dashboards** - Fast backend data management\n- **API Endpoints** - High-performance data serving\n- **Analytics \u0026 Reporting** - Complex data analysis\n- **Real-time Features** - Live data updates\n- **Custom Applications** - Modern web app development on WordPress\n\n### WordPress Integration Scenarios\n- **Hybrid Approach** - ORM for admin, WordPress native for frontend\n- **Performance Critical** - Replace slow WordPress queries\n- **Complex Queries** - Advanced filtering and relationships\n- **Custom Post Types** - Enhanced CPT management\n- **User Management** - Extended user functionality\n\n## 🔧 Configuration Options\n\n### Custom Table Prefix\n```php\ndefine('WPORM_PREFIX', 'myapp_');\nrequire_once 'path/to/wporm/bootstrap.php';\n```\n\n### Manual Initialization\n```php\ndefine('WPORM_NO_AUTO_INIT', true);\nrequire_once 'path/to/wporm/bootstrap.php';\n\n// Initialize manually when ready\n\\WordPressORM\\ORM\\ServiceProvider::boot();\n```\n\n### Development Mode\nEnable detailed logging and debugging:\n```php\ndefine('WPORM_DEBUG', true);\n```\n\n## 📁 Project Structure\n\n```\nwporm/\n├── bootstrap.php              # Main bootstrap file\n├── main.php                  # WordPress plugin entry point\n├── src/                     # Core ORM library\n│   ├── Model.php            # Base Eloquent-style model\n│   ├── Builder.php          # Fluent query builder\n│   ├── Collection.php       # Result collection\n│   ├── WordPressModel.php   # WordPress-specific base model\n│   └── Schema/              # Database schema management\n├── models/                  # WordPress core models\n│   ├── Post.php            # WordPress posts/pages/CPTs\n│   ├── User.php            # WordPress users\n│   ├── Comment.php         # WordPress comments\n│   └── ...                 # All WordPress core tables\n├── docs/                   # Comprehensive documentation\n└── examples/              # Integration examples\n```\n\n## 🤝 Contributing\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Make your changes\n4. Add tests if applicable\n5. Commit your changes (`git commit -m 'Add amazing feature'`)\n6. Push to the branch (`git push origin feature/amazing-feature`)\n7. Submit a Pull Request\n\n### Development Guidelines\n- Follow PSR-4 autoloading standards\n- Maintain WordPress compatibility\n- Include PHPDoc comments\n- Test with multiple WordPress versions\n- Ensure backward compatibility\n\n## 📝 License\n\nThis project is licensed under the GPL v2 or later - compatible with WordPress licensing requirements.\n\n## 🆘 Support \u0026 Community\n\n- **Documentation**: Comprehensive guides in `/docs` directory\n- **Examples**: Live demos and code samples included\n- **Issues**: Report bugs and request features via GitHub Issues\n- **Community**: Join discussions about WordPress ORM development\n\n## 🙏 Acknowledgments\n\n- **Inspired by [Laravel's Eloquent ORM](https://laravel.com/docs/eloquent)** - Bringing modern ORM patterns to WordPress\n- **Built for WordPress Ecosystem** - Full compatibility with WordPress standards\n- **Community Driven** - Developed with WordPress developer feedback\n- **Performance Focused** - Optimized for WordPress hosting environments\n\n---\n\n**WordPress ORM** - Bringing modern database interaction to WordPress development while maintaining the ecosystem compatibility that makes WordPress great. 🚀\n","funding_links":["https://buymeacoffee.com/misits"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmisits%2Fwordpress-orm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmisits%2Fwordpress-orm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmisits%2Fwordpress-orm/lists"}