diff --git a/content/database-orm/eloquent-orm.mdx b/content/database-orm/eloquent-orm.mdx index 8992db1..bd99744 100644 --- a/content/database-orm/eloquent-orm.mdx +++ b/content/database-orm/eloquent-orm.mdx @@ -49,6 +49,16 @@ We decided to remove the illuminate/database Eloquent ORM package from the WP Bo Remember that the Namespace inside the WordPress plugins architecture should be unique. Nonetheless, we aim to support the Eloquent ORM features, so we opted to remove it from the core, although you will still be able to use it separately. +## MySQL and SQLite + +WP Bones connects Eloquent to the database WordPress itself uses. On most sites that is MySQL, configured by `DB_HOST`, `DB_NAME`, `DB_USER` and `DB_PASSWORD` in `wp-config.php`. + +Since WP Bones 2.0.11, when WordPress runs on SQLite (WordPress Playground, WordPress Studio, or any site with the [SQLite Database Integration](https://wordpress.org/plugins/sqlite-database-integration/) plugin), Eloquent connects to the same SQLite file instead, the one the `FQDB` constant points at. The WordPress tables keep their names there, so your models work unchanged, and what they write is what `$wpdb` reads. + + +On SQLite, create your tables with WordPress, through a [migration](migrations) or `dbDelta()`, and use Eloquent for their data. A table created with Eloquent's schema builder (`\Illuminate\Database\Capsule\Manager::schema()->create()`) can be queried, but WordPress doesn't know it exists: `SHOW TABLES` and `DESCRIBE` don't list it, because the SQLite plugin keeps MySQL's catalogue only for the tables created through WordPress. + + ## Defining Models To get started, let's create a database model. Models typically live in the `plugin` directory, but you are free to place them anywhere that can be auto-loaded according to your `composer.json` file. All database models extend `Illuminate\Database\Eloquent\Model` class. diff --git a/content/getting-started/wordpress-environments.mdx b/content/getting-started/wordpress-environments.mdx index 87df46e..5b18488 100644 --- a/content/getting-started/wordpress-environments.mdx +++ b/content/getting-started/wordpress-environments.mdx @@ -146,6 +146,10 @@ Every WP Bones boilerplate ships with a Playground blueprint — see the **Playg [boilerplate page](/docs/boilerplates/overview). You can't `php bones` from Playground (no shell), but you can test the runtime behavior of an already-built plugin. +Playground runs WordPress on SQLite, not MySQL. The query builder goes through `$wpdb`, which +Playground translates, and since 2.0.11 [Eloquent](/docs/database-orm/eloquent-orm#mysql-and-sqlite) +connects to the same SQLite file, so the Database demo works there too. + ## Docker Compose (full control) If the wrappers above feel too opinionated and you want to pin every version yourself, the diff --git a/package.json b/package.json index 0fb3b11..4214d9b 100644 --- a/package.json +++ b/package.json @@ -77,5 +77,5 @@ "test": "yarn next typegen && yarn format:test && yarn lint && yarn typecheck && yarn jest", "typecheck": "tsc --noEmit" }, - "version": "2.0.10" + "version": "2.0.11" } diff --git a/public/newsletter/wpbones-2.0.11-eloquent-sqlite.png b/public/newsletter/wpbones-2.0.11-eloquent-sqlite.png new file mode 100644 index 0000000..7db81bc Binary files /dev/null and b/public/newsletter/wpbones-2.0.11-eloquent-sqlite.png differ diff --git a/public/wpkirk-api-boilerplate.zip b/public/wpkirk-api-boilerplate.zip index 9c02b90..277530d 100644 Binary files a/public/wpkirk-api-boilerplate.zip and b/public/wpkirk-api-boilerplate.zip differ diff --git a/public/wpkirk-blade-boilerplate.zip b/public/wpkirk-blade-boilerplate.zip index 3a1d06b..5a3afd1 100644 Binary files a/public/wpkirk-blade-boilerplate.zip and b/public/wpkirk-blade-boilerplate.zip differ diff --git a/public/wpkirk-boilerplate.zip b/public/wpkirk-boilerplate.zip index 9bba786..2d48c26 100644 Binary files a/public/wpkirk-boilerplate.zip and b/public/wpkirk-boilerplate.zip differ diff --git a/public/wpkirk-cpt-boilerplate.zip b/public/wpkirk-cpt-boilerplate.zip index a60a78f..ac2329c 100644 Binary files a/public/wpkirk-cpt-boilerplate.zip and b/public/wpkirk-cpt-boilerplate.zip differ diff --git a/public/wpkirk-cron-boilerplate.zip b/public/wpkirk-cron-boilerplate.zip index 26207fa..5277e14 100644 Binary files a/public/wpkirk-cron-boilerplate.zip and b/public/wpkirk-cron-boilerplate.zip differ diff --git a/public/wpkirk-database-boilerplate.zip b/public/wpkirk-database-boilerplate.zip index 2fa2be2..38ea241 100644 Binary files a/public/wpkirk-database-boilerplate.zip and b/public/wpkirk-database-boilerplate.zip differ diff --git a/public/wpkirk-hooks-boilerplate.zip b/public/wpkirk-hooks-boilerplate.zip index 45f272b..2580d47 100644 Binary files a/public/wpkirk-hooks-boilerplate.zip and b/public/wpkirk-hooks-boilerplate.zip differ diff --git a/public/wpkirk-internationalization-boilerplate.zip b/public/wpkirk-internationalization-boilerplate.zip index 179f432..ef99713 100644 Binary files a/public/wpkirk-internationalization-boilerplate.zip and b/public/wpkirk-internationalization-boilerplate.zip differ diff --git a/public/wpkirk-mantine-boilerplate.zip b/public/wpkirk-mantine-boilerplate.zip index 2b0d5c0..94df200 100644 Binary files a/public/wpkirk-mantine-boilerplate.zip and b/public/wpkirk-mantine-boilerplate.zip differ diff --git a/public/wpkirk-options-boilerplate.zip b/public/wpkirk-options-boilerplate.zip index 338af63..9b2caef 100644 Binary files a/public/wpkirk-options-boilerplate.zip and b/public/wpkirk-options-boilerplate.zip differ diff --git a/public/wpkirk-packages-boilerplate.zip b/public/wpkirk-packages-boilerplate.zip index e94fe74..2fbff11 100644 Binary files a/public/wpkirk-packages-boilerplate.zip and b/public/wpkirk-packages-boilerplate.zip differ diff --git a/public/wpkirk-reactjs-boilerplate.zip b/public/wpkirk-reactjs-boilerplate.zip index ba11a59..7065d94 100644 Binary files a/public/wpkirk-reactjs-boilerplate.zip and b/public/wpkirk-reactjs-boilerplate.zip differ diff --git a/public/wpkirk-routes-boilerplate.zip b/public/wpkirk-routes-boilerplate.zip index d2bfdab..bfb82fc 100644 Binary files a/public/wpkirk-routes-boilerplate.zip and b/public/wpkirk-routes-boilerplate.zip differ diff --git a/public/wpkirk-typescript-boilerplate.zip b/public/wpkirk-typescript-boilerplate.zip index 0421c0f..e8e3cfb 100644 Binary files a/public/wpkirk-typescript-boilerplate.zip and b/public/wpkirk-typescript-boilerplate.zip differ