Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.exowizz.com/llms.txt

Use this file to discover all available pages before exploring further.

This guide walks you through the core Exo concept: Resource creation. You will define one Resource and then use the API and triggers generated from it.

What is a Resource?

A Resource is a PHP class that tells Exo:
  • Which model to expose (for example: User, Contact, Invoice)
  • Which data shape to return through API and webhooks
  • Which trigger events to emit (on_create, on_update, on_delete)

Generate it

php artisan exo:resource UserResource --model="App\Models\User" --triggers=on_create,on_update,on_delete
This creates app/Exo/Resources/UserResource.php.

Define the required methods

Every Resource implements name(), model(), triggers(), and transform().
<?php

namespace App\Exo\Resources;

use Exowizz\Exo\Resource;
use Illuminate\Database\Eloquent\Model;

class UserResource extends Resource
{
    public function name(): string
    {
        return 'user';
    }

    public function model(): string
    {
        return 'App\\Models\\User';
    }

    public function triggers(): array
    {
        return ['on_create', 'on_update', 'on_delete'];
    }

    public function transform(Model $model): array
    {
        return [
            'id' => $model->id,
            'name' => $model->name,
            'email' => $model->email,
            'created_at' => $model->created_at,
            'updated_at' => $model->updated_at,
        ];
    }
}

What Exo generates from this Resource

After app boot, Exo auto-discovers your Resource and registers:
  • GET /exo-api/resources (resource metadata)
  • GET /exo-api/resources/user (list)
  • GET /exo-api/resources/user/{id} (single record)
  • POST /exo-api/resources/user (create)
  • PUT /exo-api/resources/user/{id} (update)
  • DELETE /exo-api/resources/user/{id} (delete)
  • Trigger emission for on_create, on_update, and on_delete

Test the generated API

Confirm registration:
curl -H "Authorization: Bearer YOUR_TOKEN" \
     http://your-app.test/exo-api/resources
Create a user:
curl -X POST \
     -H "Authorization: Bearer YOUR_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{"name":"Jane Smith","email":"[email protected]","password":"secret-password"}' \
     http://your-app.test/exo-api/resources/user
List users:
curl -H "Authorization: Bearer YOUR_TOKEN" \
     http://your-app.test/exo-api/resources/user

Add medium-level controls

Once this works, add optional methods for:
  • Validation with createRules() and updateRules()
  • Ownership with ownerColumn() and is_admin callback
  • Query control with searchableColumns() or applySearch()
  • Operation flags with supportsCreate(), supportsUpdate(), supportsDelete()

Next steps

Resource guides

Continue with transformers, CRUD behavior, ownership, and search.

Webhooks

See how your Resource triggers become webhook deliveries.