Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop-4'
Browse files Browse the repository at this point in the history
# Conflicts:
#	composer.json
  • Loading branch information
dimitriBouteille committed Dec 14, 2024
2 parents 5373837 + 103f9b0 commit fc4a8db
Show file tree
Hide file tree
Showing 94 changed files with 2,544 additions and 1,324 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ jobs:
- name: "Install composer dependencies"
run: composer install --prefer-dist --no-progress

# WordPress tests works only with PHPUnit 9.x :(
# https://github.com/dimitriBouteille/wp-orm/actions/runs/11192354429/job/31116408495
- name: "Install PHPUnit v9"
run: |
composer require --dev phpunit/phpunit ^9.0 -W
composer require --dev yoast/phpunit-polyfills ^3.0 -W
- name: "Install WP"
shell: bash
run: ./config/scripts/install-wp-tests.sh wordpress_test root '' 127.0.0.1:3306 ${{ matrix.wp_version }}
Expand Down
3 changes: 2 additions & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
;

$header = <<<EOF
Copyright (c) 2024 Dimitri BOUTEILLE (https://github.com/dimitriBouteille)
Copyright © Dimitri BOUTEILLE (https://github.com/dimitriBouteille)
See LICENSE.txt for license details.
Author: Dimitri BOUTEILLE <[email protected]>
Expand All @@ -40,6 +40,7 @@
'no_unused_imports' => true,
'align_multiline_comment' => true,
'array_indentation' => true,
'blank_line_after_opening_tag' => false,
'header_comment' => [
'header' => $header,
'comment_type' => 'PHPDoc',
Expand Down
File renamed without changes.
30 changes: 9 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,32 @@

![GitHub Release](https://img.shields.io/github/v/release/dimitriBouteille/wp-orm) [![tests](https://img.shields.io/github/actions/workflow/status/dimitriBouteille/wp-orm/tests.yml?label=tests)](https://github.com/dimitriBouteille/wp-orm/actions/workflows/tests.yml) [![Packagist Downloads](https://img.shields.io/packagist/dt/dbout/wp-orm?color=yellow)](https://packagist.org/packages/dbout/wp-orm) ![Eloquent version](https://img.shields.io/packagist/dependency-v/dbout/wp-orm/illuminate%2Fdatabase?color=orange)

> [!IMPORTANT]
> The phinx package will be removed in a future release in order to use the Laravel migration system. It is therefore advisable to stop using the tool. [More info](https://github.com/dimitriBouteille/wp-orm/issues/27).
WordPress ORM with Eloquent is a small library that adds a basic ORM into WordPress, which is easily extendable and includes models for core WordPress models such as posts, post metas, users, comments and more.
The ORM is based on [Eloquent ORM](https://laravel.com/docs/eloquent) and uses the WordPress connection (`wpdb` class).

> 💡 To simplify the integration of this library, we recommend using WordPress with one of the following tools: [Bedrock](https://roots.io/bedrock/), [Themosis](https://framework.themosis.com/) or [Wordplate](https://github.com/wordplate/wordplate#readme).
> [!TIP]
> To simplify the integration of this library, we recommend using WordPress with one of the following tools: [Bedrock](https://roots.io/bedrock/), [Themosis](https://framework.themosis.com/) or [Wordplate](https://github.com/wordplate/wordplate#readme).
### Features
## Features

- ✅ Support core WordPress models: `Comment`, `Option`, `Post`, `TermTaxonomy`, `Term`, `User`, `PostMeta` and `UserMeta`
- ✅ Support core WordPress post type: `Article`, `Attachment` and `Page`
- ✅ Based on core WordPress database connection (`wpdb` class), no configuration required !
- ✅ Custom functions to filter models with meta
- ❤️ Easy integration of a custom post type
- ✅ Meta casting (e.g. [Attribute Casting](https://laravel.com/docs/eloquent-mutators#attribute-casting))
- ❤️ Easy integration of a custom post and comment type
- ❤️ Easy model creation for projects with custom tables
- ❤️ All the features available in Eloquent, are usable with this library !

**Not yet developed but planned in a future version:**

- 🗓️ Create custom comment type
- 🗓️ Meta casting (e.g. [Attribute Casting](https://laravel.com/docs/10.x/eloquent-mutators#attribute-casting))
- 🗓️ [Create migration tool with Eloquent](https://github.com/dimitriBouteille/wp-orm/issues/28)

### Documentation
## Documentation

This documentation only covers the specific points of this library, if you want to know more about Eloquent, the easiest is to look at [the documentation of Eloquent](https://laravel.com/docs/10.x/eloquent) :)
This documentation only covers the specific points of this library, if you want to know more about Eloquent, the easiest is to look at [the documentation of Eloquent](https://laravel.com/doc/eloquent).

- [Installation](#installation)
- [Use WordPress core models](doc/wordpress-core-models.md)
- [Filter data](/doc/filter-data.md)
- [With findOneBy*](/doc/filter-data.md#with-findoneby)
- [With taps](/doc/filter-data.md#with-taps)
- [With query builder](/doc/filter-data.md#with-query-builder)
- [Events](/doc/events.md)
- [Create custom model](doc/create-model.md)
- [Generic Model](doc/create-model.md#generic-model)
- [Custom Post Type Model](doc/create-model.md#custom-post-type-model)
- [~~Migration with Phinx~~](doc/migration.md)
You can find all the documentation in [the wiki](https://github.com/dimitriBouteille/wp-orm/wiki).

## Installation

Expand Down
32 changes: 14 additions & 18 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dbout/wp-orm",
"description": "WordPress ORM with Eloquent and Phinx.",
"description": "WordPress ORM with Eloquent.",
"type": "package",
"license": "MIT",
"authors": [
Expand All @@ -11,7 +11,7 @@
"role": "Developer"
}
],
"keywords": ["wordpress", "wp", "orm", "database", "eloquent", "db", "sql", "migration", "phinx"],
"keywords": ["wordpress", "wp", "orm", "database", "eloquent", "db", "sql", "migration"],
"homepage": "https://github.com/dimitriBouteille/wp-orm",
"support": {
"issues": "https://github.com/dimitriBouteille/wp-orm/issues",
Expand All @@ -20,17 +20,14 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.1",
"robmorgan/phinx": "^0.12.5",
"illuminate/database": "^10.0"
"php": ">=8.2",
"laravel/serializable-closure": "^1.3",
"illuminate/database": "^11.0"
},
"suggest": {
"illuminate/events": "Add events to your models"
},
"autoload": {
"files": [
"src/includes/migrations.php"
],
"psr-4": {
"Dbout\\WpOrm\\": "src/"
}
Expand All @@ -41,20 +38,19 @@
}
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.28",
"phpstan/phpstan": ">=1.10.59",
"phpstan/phpstan-phpunit": "^1.3",
"phpstan/extension-installer": "^1.3",
"rector/rector": "^1.0",
"friendsofphp/php-cs-fixer": "^3.64",
"phpstan/phpstan": "^1.12",
"phpstan/extension-installer": "^1.4",
"szepeviktor/phpstan-wordpress": "^1.3",
"phpunit/phpunit": "^9.6",
"yoast/phpunit-polyfills": "^2.0",
"roots/wordpress": "^6.5"
"rector/rector": "^1.2",
"roots/wordpress": "^6.6",
"phpunit/phpunit": "^11.0",
"yoast/phpunit-polyfills": "^3.0"
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": true,
"roots/wordpress-core-installer": true
"roots/wordpress-core-installer": true,
"phpstan/extension-installer": true
}
},
"extra": {
Expand Down
23 changes: 18 additions & 5 deletions config/scripts/install-wp-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,22 @@ WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib}
WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress}

download() {
if [ `which curl` ]; then
curl -s "$1" > "$2";
elif [ `which wget` ]; then
wget -nv -O "$2" "$1"
fi
if [ `which curl` ]; then
curl -s "$1" > "$2";
elif [ `which wget` ]; then
wget -nv -O "$2" "$1"
else
echo "Error: Neither curl nor wget is installed."
exit 1
fi
}

# Check if svn is installed
check_svn_installed() {
if ! command -v svn > /dev/null; then
echo "Error: svn is not installed. Please install svn and try again."
exit 1
fi
}

if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+\-(beta|RC)[0-9]+$ ]]; then
Expand Down Expand Up @@ -72,6 +83,7 @@ install_wp() {
if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
mkdir -p $TMPDIR/wordpress-trunk
rm -rf $TMPDIR/wordpress-trunk/*
check_svn_installed
svn export --quiet https://core.svn.wordpress.org/trunk $TMPDIR/wordpress-trunk/wordpress
mv $TMPDIR/wordpress-trunk/wordpress/* $WP_CORE_DIR
else
Expand Down Expand Up @@ -116,6 +128,7 @@ install_test_suite() {
# set up testing suite
mkdir -p $WP_TESTS_DIR
rm -rf $WP_TESTS_DIR/{includes,data}
check_svn_installed
svn export --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
svn export --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
fi
Expand Down
25 changes: 0 additions & 25 deletions doc/available-filters.md

This file was deleted.

63 changes: 0 additions & 63 deletions doc/create-model.md

This file was deleted.

58 changes: 0 additions & 58 deletions doc/events.md

This file was deleted.

Loading

0 comments on commit fc4a8db

Please sign in to comment.