Getting Started

Set up your first domain context inside an Obelaw application.

Getting Started with Domains

This guide will walk you through installing the Obelaw framework and defining your first business domain.

Installation

To start using domains in your Laravel project, install the core Obelaw framework package:

composer require obelaw/framework

Structure of a Bounded Context

In Domain-Driven Design, a business domain represents a Bounded Context. In Obelaw, a domain is structured as an isolated directory with its own namespaces.

You can place your domains directory anywhere, but the recommended path is under a domains/ folder in your application root:

app/
bootstrap/
config/
domains/
  └── Inventory/      <-- Bounded Context
  └── Billing/        <-- Bounded Context

Registering Your Domains

Once your domains are created, they must be registered with the Obelaw Service Provider. Open your app/Providers/AppServiceProvider.php (or create a dedicated DomainServiceProvider.php) and register your domain managers:

use App\Providers\ServiceProvider;
use Obelaw\Framework\Facades\Domains;
use Domains\Inventory\InventoryManager;

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        // Register the inventory domain under the 'inventory' key
        Domains::register('inventory', InventoryManager::class);
    }
}

Now, your domain is registered and can be accessed fluently from any part of the application:

$stock = ium()->inventory()->stock()->available($productId);

Next Steps

Now that you have registered your domain, learn about the architecture layout: