Skip to content
Dimitri BOUTEILLE edited this page Nov 26, 2024 · 5 revisions

Welcome to the wp-rom wiki !

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.

Installation

Requirements

The server requirements are basically the same as for WordPress with the addition of a few ones :

Installation

You can use Composer. Follow the installation instructions if you do not already have composer installed.

composer require dbout/wp-orm

In your PHP script, make sure you include the autoloader:

require __DIR__ . '/vendor/autoload.php';

🎉 You have nothing more to do, you can use the library now! Not even need to configure database accesses because it's the wpdb connection that is used.

Facades

Facades provide a "static" interface to classes that are available in the application's service container. Laravel contains several facades including DB which is used to easily access the database.

If you want to use the facades, you must initialize the container yourself. The simplest solution for is to create a mu-plugin, here’s an example :

use Dbout\WpOrm\Orm\Database;
use Illuminate\Container\Container;
use Illuminate\Support\Facades\Facade;

$container = new Container();
$container->instance('db', Database::getInstance());
Facade::setFacadeApplication( $container );

You can now use the DB facade without any problems :

use \Illuminate\Support\Facades\DB;

$count = DB::raw('count + 1');
Clone this wiki locally