Installation

Requirements

RequirementVersion
PHP>= 8.0
WordPress>= 6.0
Composer2.x
wpzylos-core^1.0
wpzylos-database^1.0

Install via Composer

composer require KYNetCode/wpzylos-model

This will also install the required wpzylos-core and wpzylos-database packages if not already present.

Register the Service Provider

In your plugin bootstrap file, register the ModelServiceProvider with your application:

<?php

declare(strict_types=1);

use WPZylos\Framework\Model\ModelServiceProvider;

// After creating your Application instance
$app->register(new ModelServiceProvider());

The service provider performs two actions:

  1. Register phase: Binds ModelResolver as a singleton (model.resolver) in the container
  2. Boot phase: Injects the ApplicationInterface into the base Model class via Model::setApplication($app)

Verify Installation

Create a simple model to verify everything is working:

<?php

declare(strict_types=1);

namespace App\Models;

use WPZylos\Framework\Model\Model;

class TestModel extends Model
{
    protected static string $table = 'test';
    protected array $fillable = ['name'];
}

If the table exists, you should be able to call:

$items = TestModel::all();

Development Setup

For development and testing:

git clone https://github.com/KYNetCode/wpzylos-model.git
cd wpzylos-model
composer install

Run quality checks:

composer test      # Run PHPUnit tests
composer analyze   # Run PHPStan
composer cs        # Check code style
composer qa        # Run all quality checks